我们可以在 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 functionfunction
onConfirm(button) { // if press 'Yes' if
(button === 1){ navigator.app.exitApp(); }}// PhoneGap Notification 提供的 Confirm APIfunction
showConfirm() { navigator.notification.confirm( '确定要退出程序吗?',
// message onConfirm,
// callback function '标题',
// title 'Yes,No'
// confirm 选项,用逗号隔开 );}
本文介绍了在PhoneGap1.5.0中使用`navigator.app.exitApp()`方法来正确退出应用程序的方式,并提供了一个确认对话框示例,允许用户选择是否退出。
1万+

被折叠的 条评论
为什么被折叠?



