How to prevent Android from closing web-application when backbutton is pressed?

后端 未结 3 634
野性不改
野性不改 2020-12-19 17:48

I am developing a HTML5 web-application and compiling it with Cordova (phonegap) 1.7.

I want to override the Android backbutton so that I can call window.history.ba

3条回答
  •  盖世英雄少女心
    2020-12-19 17:53

    I solved my own question by adding the code below to the DefaultActivity.java file to prevent the default android behavior, and keeping the JavaScript code as stated in the question:

    @Override
    public void onBackPressed() {
       return;
    }
    

    I hope this helps someone in the future with the same problem!

提交回复
热议问题