Open full view…

Android Back Button

Mon, 02 Jan 2017 11:29:02 GMT

Hi All, I have developed an android app with framework7. Everything is working perfectly. But when I am pressing hardware back button, the app exits, It is not going to the main view,,Plss anyone help..How to solve this problem

Mon, 02 Jan 2017 14:32:42 GMT

document.addEventListener("backbutton", onBackKeyDown, false); function onBackKeyDown() { //do stuff }

Sun, 08 Jan 2017 14:54:12 GMT

Can you send full code..??I didnt understand plss..

Kerry D
Mon, 09 Jan 2017 10:57:09 GMT

Add that code to your application's Javascript file. The first line is an event listener for when the Back Button is pressed. You can see it in the Cordova docs here Note that you can only monitor the back button when your app is packaged in Cordova or Phonegap. Add the event handler to the 'onDeviceReady()' block.

Fri, 06 Oct 2017 06:40:11 GMT

Hello guys i am new here, writing for the first time but i guess this code will resolve all the issue related to android back button for Popup, modal, side panel and page back. Have a look at the code. /* *Device Ready* Funtion */ function onDeviceReady() { document.addEventListener("backbutton", onBackKeyDown, false); } function onBackKeyDown() { var cpage = mainView.activePage; var cpagename =; console.log(cpagename); if (($$('#left_panel').hasClass("active")) || ($$('#right_panel').hasClass("active"))) { // #left_panel and #right_panel are id of both panels. myApp.closePanel(); return false; } else if ($$('.modal-in').length > 0) { myApp.closeModal(); return false; } else if (cpagename == "index") { myApp.confirm("Are you sure you want to exit?", function() { // var deviceType = device.platform; // if(deviceType == "Android" || deviceType == "android"){; // } }, function() { }); } else { mainView.router.back(); } }