关闭Android应用Jquery的 - 的PhoneGap [英] Close Android app Jquery - Phonegap
本文介绍了关闭Android应用Jquery的 - 的PhoneGap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想结束我的PhoneGap的Android应用程序与下面的一段code的:
I'm trying to close my Phonegap Android app with the following piece of code:
document.addEventListener("backbutton", function () {
if ($('.screenshot').is(":visible")) {
if (confirm('Afsluiten?')){
setTimeout( function() { navigator.app.exitApp(); });
}
else {
'';
}
}
else {
$(".items , .screenshot").show();
$(".content , .openbrowser , .html5vid , .introtekst_gal" ).hide();
$(".terug").hide();
}
}, true);
它的工作原理一次:pressing后退按钮,然后确定关闭该应用程序,符合市场预期。
It works once: Pressing the back-button and then "Ok" closes the app, as expected.
但是,当我不喜欢这样,应用程序没有关闭了:
But when I do it like this, the app doesn't close anymore:
- preSS后退按钮(弹出所示)
- preSS取消(弹出消失)
- preSS后退按钮(弹出所示)
- preSSOK(弹出消失和应用程序应该关闭,但没有)
我在做什么错了?
推荐答案
你可以试试这个code:
you can try this code:
document.addEventListener("backbutton", function () {
navigator.notification.confirm(
'Do you want to quit',
onConfirmQuit,
'QUIT TITLE',
'OK,Cancel'
);
}, true);
function onConfirmQuit(button){
if(button == "1"){
navigator.app.exitApp();
}
}
这篇关于关闭Android应用Jquery的 - 的PhoneGap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文