Reputation: 11
We have developed an application in jQuery integrated with android (which has only one activity). From this activity we are loading an HTML file, on this file we are showing and hiding the div contents. On viewing the web pages provided here and pressing back button provided in android, the application exits. We want the application to go to the previous page on clicking the back button.
(On clicking the android back button we need to show the hidden div contents and on clicking the android back button from the div contents page the application should exit.)
Upvotes: 1
Views: 5727
Reputation: 979
Try this:
function onDeviceReady() {
// Add this line to the on onDeviceReady() function
document.addEventListener("backbutton", onBackKeyDown, false);
}
// Handle back button hardware
function onBackKeyDown(e) {
e.preventDefault(); // the default action of the event e should not be triggered.
history.back(1); // load the previous window.location
}
Upvotes: 0
Reputation: 32222
Use this code in your HTML page to handle back button pressed
document.addEventListener("backbutton", onBackKeyDown, false);
function onBackKeyDown() {
// Handle the back button
}
Upvotes: 2