我们可以在 PhoneGap 1.5.0 的 cordova-1.5.0.js 看到:
1
2
3
4
5
6
7
8
9
10
|
/*
* DEPRECATED
* This is only for Android.
*
* This terminates the activity!
*/
Device.prototype.exitApp =
function
() {
console.log(
"Device.exitApp() is deprecated. Use App.exitApp()."
);
navigator.app.exitApp();
};
|
改用 navigator.app.exitApp(); 可正常运行;
修改之后:
// callback function
function
onConfirm(button) {
// if press 'Yes'
if
(button === 1){
navigator.app.exitApp();
}
}
// PhoneGap Notification 提供的 Confirm API
function
showConfirm() {
navigator.notification.confirm(
'确定要退出程序吗?'
,
// message
onConfirm,
// callback function
'标题'
,
// title
'Yes,No'
// confirm 选项,用逗号隔开
);
}