后退按钮确认退出应用程序的Android + PhoneGap的+的jQuery [英] backbutton confirm exit app android + phonegap + jquery
本文介绍了后退按钮确认退出应用程序的Android + PhoneGap的+的jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何处理物理后退按钮在Android中使用jQuery Mobile的PhoneGap的在线系统中? 我想显示确认退出应用程序(是 - 否)。我尝试过很多方法,但没有什么工作。
How can I handle the Physical Back Button in Android by using jQuery Mobile within Phonegap online system? I want to show confirm to exit the app (YES - NO). I tried many ways but nothing is working.
推荐答案
试试这个:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
document.addEventListener("backbutton", onBackKeyDown, false); //Listen to the User clicking on the back button
}
function onBackKeyDown(e) {
e.preventDefault();
navigator.notification.confirm("Are you sure you want to exit ?", onConfirm, "Confirmation", "Yes,No");
// Prompt the user with the choice
}
function onConfirm(button) {
if(button==2){//If User selected No, then we just do nothing
return;
}else{
navigator.app.exitApp();// Otherwise we quit the app.
}
}
这篇关于后退按钮确认退出应用程序的Android + PhoneGap的+的jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文