我创造了 Android app
运用 cordova 2.6.0
。我实施了一个 menu
我的应用中的功能使用 html
加价和 jQuery
切换与设备的交互 menubutton
。但我无法想象达到以下要求,表现得像本机应用程序。
需求
该 menu
应该隐藏在按下设备上 backbutton
如果 menu
是 visible
。如果 menu
是不可见的 backbutton
现在应该正常行事,这应该是应该的 exit
该 app
或者去 back history
。
这是我的代码
document.addEventListener('deviceready', function(){
document.addEventListener('menubutton', function(){
//Toggle Menu
//Which is working fine
});
document.addEventListener('backbutton', function(){
if(menu is visible) {
//Hide the menu
//This is also working fine
return false;
}
//BUT the default action of backbutton has gone. It cannot exit the app , neither it brings to back history.
//return true;
//I have also tried to return boolean true , but facing the same problem.
});
}, false);
实际问题
如果我附上了 eventlistener
对于 backbutton
设备的 Back Button
被禁用,它不能正常工作。
我的问题是
是 document.addEventListener('backbutton', function(){});
超过设备的后退按钮?如何摆脱它?
这是在Android 4.1.2设备上发生的