Software Archive
Read-only legacy content
17061 Discussions

Hardware Back button Event

Puspad_s_
Beginner
346 Views

Hello

    I want to track hardware back button event on my app for android. If user press hardware back button from device I want to track this event.

I had tried these below function already but its not working anymore.

document.addEventListener("intel.xdk.device.ready",function() {

    //start grabbing the Android hardware back button
    intel.xdk.device.addVirtualPage(); 
    
},false);

        
document.addEventListener("intel.xdk.device.hardware.back", function() {
    
    //continue to grab the back button
    intel.xdk.device.addVirtualPage(); 
    
    document.getElementsByTagName("body")[0].innerHTML += "Hardware back button pressed
";
    
}, false); 

Currently my app is based on appframework 3. 

Anyone has idea how to do it right way?

Thank you!

 

 

0 Kudos
4 Replies
Elroy_A_Intel
Employee
346 Views

I recommend using the Apache Cordova "backbutton" event instead for tracking when the user presses the Android back button. You can find information at https://cordova.apache.org/docs/en/dev/cordova/events/events.backbutton.html. Currently, the intel.xdk apis are not being maintained for current mobile platform versions.

0 Kudos
Ariska_Hidayat
Beginner
346 Views

Until now I still can not make a back button. Does anyone know? thx

0 Kudos
Pamela_H_Intel
Moderator
346 Views

Ariska - Adding a back button differs for different templates. Do you just want to create a back button by hand, or are you using a particular template? If you want backbuttons on a tab view, for example, take a look at the Yoga sample. In the Yoga sample app look at the bottom of the index.html file. The back buttons are enabled when you don't use the clearhistory() function.

0 Kudos
Joko_P_
Beginner
346 Views

I have the same problem. But when I change theme into device native, or android - light or ios it works. Only when I use App Framework theme backbutton close the app.

0 Kudos
Reply