如何在Phonegap中完全退出Android应用程序?

时间:2016-03-21 10:55:15

标签: cordova exit

应用程序成功存在,但它仍然作为活动应用程序保留在后台?如何完全退出?

这是我的代码:

function showExitDialog() {
navigator.notification.confirm(
    ("Do you want to Exit?"), // message
    alertexit, // callback
    'Exit the application?', // title
    'YES,NO' // buttonName
);
}


function alertexit(button){

     if(button=="1" || button==1 && navigator.app) {
         navigator.app.exitApp();
     } else if(button=="1" || button==1 && navigator.device) {
         navigator.device.exitApp();
     }
}

1 个答案:

答案 0 :(得分:1)

在该文件的app.java中找到cordovaLib/src/org/apache/cordova/app.java文件,您将找到名为public void exitApp()的方法,将该方法更改为以下

public void exitApp() {

        this.webView.postMessage("exit", null);
        finish();  
    }

希望它会对你有所帮助。