Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Puspad_s_
Beginner
80 Views

Hardware Back button Event

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!

 

 

Tags (2)
0 Kudos
4 Replies
Elroy_A_Intel
Employee
80 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.

Ariska_Hidayat
Beginner
80 Views

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

Pamela_H_Intel
Moderator
80 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.

Joko_P_
Beginner
80 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.

Reply