是否可以捕获Android设备后退按钮的按住事件以关闭应用程序?
干杯 保罗
答案 0 :(得分:5)
是的,请参阅PhoneGap API: http://docs.phonegap.com/en/1.0.0/phonegap_events_events.md.html
// Call onDeviceReady when PhoneGap is loaded.
//
// At this point, the document has loaded but phonegap.js has not.
// When PhoneGap is loaded and talking with the native device,
// it will call the event `deviceready`.
//
document.addEventListener("deviceready", onDeviceReady, false);
// PhoneGap is loaded and it is now safe to make calls PhoneGap methods
//
function onDeviceReady() {
// Register the event listener
document.addEventListener("backbutton", onBackKeyDown, false);
}
// Handle the back button
//
function onBackKeyDown() {
}
答案 1 :(得分:0)
没有只有听众,但我认为你可以使用onKeyDown()
监听器制作自己的长背钥匙监听器,甚至更好,你可以试试onLongKeyDown()
监听器。 ..