I want to disable hardback button on android using Cordova or android I try to put a code in android as well as android but in android, code created by Cordova there is the only main activity and it disables back button on my 1st page that is login page on other pages on click of back button it exits the app or close the app I want it to disable throughout the application
this is the android main activity code:-
@Override
public void onBackPressed() {
}
public boolean onKeyDown(int keyCode, KeyEvent event) {
// if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
// appView.loadUrl("javascript: onBackKeyDown()");
// Log.d("logcat", "--------------click click-----------------------------");
// super.onBackPressed();
// return true;
// }
// return (keyCode == KeyEvent.KEYCODE_BACK ? true : super.onKeyDown(keyCode, event));
return true;
}
on Cordova onDeviceReady :-
document.addEventListener("backbutton", onBackKeyDown, false);
function onBackKeyDown() {
console.log("back keypressed")
return false;
}
but this code run on Cordova but still app closed