这是我的代码
//This is an event that fires when a PhoneGap application is put into the background.
document.addEventListener("pause", onPause, false);
//This is an event that fires when a PhoneGap application is retrieved from the background.
document.addEventListener("resume", onResume, false);
// Handle the pause event
function onPause(){
console.log("pause : app is put into background");
}
// Handle the resume event
function onResume() {
console.log("resume : app is put into foreground");
}
当我按下主页按钮时,控制台中没有日志,但是当我单击应用程序(使其处于前台)时,我的日志是
2011-11-22 12:11:37.206 Event[644:207] [INFO] pause : app is put into background
2011-11-22 12:11:37.206 Event[644:207] [INFO] resume : app is put into foreground
我不知道为什么当它进入前台时会调用暂停函数。
我做错了什么吗?
这是来自文档
iOS 怪癖 http://docs.phonegap.com/en/1.0.0/phonegap_events_events.md.html#Events
在暂停处理程序中,任何通过 Objective-C 的调用都将不起作用,任何交互式调用(如警报)也将不起作用。这意味着您无法调用 console.log (及其变体),或来自插件或 PhoneGap API 的任何调用。仅当应用程序恢复时才会处理这些(在下一个运行循环中处理)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)