我在Android应用程序中使用PhoneGap的工作。我需要使用下面的code处理设备后退按钮功能:
I am working on android application using PhoneGap. I need to handle Device back button functionality by using the below code:
import com.phonegap.DroidGap;
public Class MyClass extends DroidGap {
appView.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
finish();
return true;
}
return onKeyDown(keyCode, event);
}
});
}
通过使用上述code,应用程序获得退出,因为我已经使用结束();
但我想没有什么应该发生在点击设备的后退按钮的。我怎样才能acheive呢?请帮我。
By using the above code, Application getting exited because i have used finish();
But i want nothing should be happened on click of Device back button. How can i acheive that? Please help me.
为什么你需要在Java级别做到这一点?您可以使用的Javascript实现这个的PhoneGap的事件API
Why do you need to do this at the Java level? You can achieve this with Javascript using Phonegap's Event API
document.addEventListener("backbutton", onBackKeyDown, false);
function onBackKeyDown(e) {
e.preventDefault();
}
上一篇:未定义的引用“简历:: initModule_nonfree()”在Android中简历、未定义、Android、initModule_nonfree
下一篇:Android的CalendarProvider事件颜色颜色、事件、Android、CalendarProvider