我正在与Angular JS结合使用PhoneGap应用程序。首先关闭所有信息,为您提供一些信息:
现在我用这段代码覆盖了android的backbutton功能:
CommonService.checkConnection();
if (sessionStorage.Device == "Android Mobile" || sessionStorage.Device == "Android Tablet") {
document.addEventListener("backbutton", onBackKey, false);
}
我的onBackKey
函数如下所示:
function onBackKey() {
alert("onBackKey");
}
现在这个函数被调用,因为我需要但是android应用程序也会崩溃(当我点击android中的后退按钮时)。
编辑: -
我收到错误日志: -
07-09 14:13:26.925: D/WebView(24377): loadUrl=javascript:cordova.fireDocumentEvent('backbutton');
07-09 14:13:26.939: D/CordovaActivity(24377): onMessage(exit,null)
07-09 14:13:27.076: D/CordovaActivity(24377): Paused the application!
07-09 14:13:27.076: D/ActivityThread(24377): ACT-AM_ON_PAUSE_CALLED ActivityRecord{41f61d68 token=android.os.BinderProxy@41f61538 {com.Corecon.coreconapp/com.Corecon.coreconapp.CoreconMobile}}
07-09 14:13:27.079: W/PluginManager(24377): THREAD WARNING: exec() call to App.exitApp blocked the main thread for 140ms. Plugin should use CordovaInterface.getThreadPool().
07-09 14:13:27.089: D/ActivityThread(24377): ACT-PAUSE_ACTIVITY_FINISHING handled : 0 / android.os.BinderProxy@41f61538
android.view.WindowLeaked: Activity com.test.testapp has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{425281b8 V.E..... R.....I. 0,0-698,384} that was originally added here 07-08 12:45:43.883: E/WindowManager(14991)
我无法弄清楚为什么会这样。你能帮我解决这个问题吗,你有什么想法为什么按下后退按钮会迫使我的应用程序崩溃?