[英]back button of smartphone doesn't work
I am developing an app using MoSync SDK.我正在使用 MoSync SDK 开发应用程序。
I have 5 pages.我有 5 页。 Whenever I try to return back to the previous one, my smartphone's back button doesn't work.
每当我尝试返回上一个时,我的智能手机的返回按钮都不起作用。 I have used the following code:
我使用了以下代码:
//back button (on Android).
document.addEventListener(
"backbutton",
function()
{
window.history.back()
},
true
);
// Close the application when the back key is pressed.
document.addEventListener(
"backbutton",
function()
{
mosync.app.exit();
},
false
);
You don't have to deal with it, but if you actually want to, this is the way:你不必处理它,但如果你真的想,这是这样的:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK ) {
// do something on back.
return true;
}
return super.onKeyDown(keyCode, event);
}
Take a look at this link: http://developer.android.com/training/implementing-navigation/temporal.html看看这个链接: http : //developer.android.com/training/implementing-navigation/temporal.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.