Android的后退按钮退出应用,而不是运行其新的code [英] Android Back Button Exiting Apps Instead Of Running Its New Code

查看:146
本文介绍了Android的后退按钮退出应用,而不是运行其新的code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在英特尔XDK使用HTML,JavaScript的将某个应用为Android。我用下面的code覆盖了Android后退按钮功能和Android菜单按钮。

I am making an app for Android using HTML-JavaScript on Intel-XDK. I'm overriding the Android Back Button function and Android Menu Button using the following code.

<script src="cordova.js" type="text/javascript"></script>
<script type="text/javascript">
/* Android Back Button
----------------------------------------------- */
function backButtonPressed() {
    isPaused = true; // To Pause        
}
document.addEventListener("backbutton", backButtonPressed, false);

/* Android Menu Button
----------------------------------------------- */
function menuButtonPressed() {
    isPaused = false; // To false
}
document.addEventListener("menubutton", menuButtonPressed, false);
</script>

这两个在英特尔XDK效仿完美的工作。但是,当我在Android设备上运行它们,菜单按钮code是工作,但后退按钮code不能正常工作,它的退出应用程序。怎样做才能阻止这种行为(即退出应用程序),并开始经营自己的code?

Both are working perfectly in Intel-XDK Emulate. But when I am running them in an android device, the menu button code is working but back button code is not working and it's exiting the app. What to do to stop this behavior (ie, exiting the app) and start running my own code?

注:我也尝试从 https://software.intel code。 COM / EN-US /节点/ 493108 但仍处于移动不工作,工作在模拟器。

Note: I also tried code from https://software.intel.com/en-us/node/493108 but still not working in Mobile and is working in Emulator.

推荐答案

终于得到了这个问题的解决方案,那就是我被忽略了弹出窗口。

Finally got the solution of this problem and that is the popup that I was ignoring.

在这里输入的形象描述

总之,应用preVIEW,仿真器或调试选项卡是不完美的,给你完美的答案,以便采取建立APK和你的设备上安装后的决定。

In short, App Preview, Emulator or the Debug Tab are not perfect to give you the perfect answer so take decisions after building the APK and installing it on your device.

这篇关于Android的后退按钮退出应用,而不是运行其新的code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆