关闭(杀)和android用Phonegap开发的App

Closing (killing) and android App developed with Phonegap

我正在用 Phonegap 开发一个小应用程序。我想为用户添加一个按钮 close/kill 应用程序,但它仍然在后台 运行。我使用了这个线程中的代码: Is it really posible to close a PhoneGap App? 并使用了以下函数:

function CloseApp() {
    if (confirm('Close this App?')){
        if (navigator.app) {
            navigator.app.exitApp();
        }else if (navigator.device) {
            navigator.device.exitApp();
        }
    }
}

navigator.app.exitApp()将关闭应用程序,它可能显示在最近的应用程序选项卡中,但应用程序已关闭。如果您在关闭后再次打开该应用程序,它将加载完整的应用程序,如果该应用程序未关闭,您将看到最后的 activity 页。