我正在尝试使用 phonegap 和 LocalNotification 插件开发一个 android 应用程序。 我想在 onPause 中运行我的应用程序, 在我的 index.html 上
document.addEventListener("pause", onPause, false);
函数 onPause() { //处理暂停事件
setInterval( function() {
Ext.data.JsonP.request({
url: 'http://convert4mobile.net/backend/API/qr/push.php',
callbackKey: 'callback',
success: function(data)
{
if(data.success == true)
{
if (typeof plugins !== "undefined") {
window.plugins.localNotification.add({
date : new Date(),
message : data.time+"\r\n"+data.msg,
ticker : "A new code was generated",
repeatDaily : false,
id : 4
});
}
}
}
});
} , 2000);
当通过主页按钮/结束通话按钮关闭/最小化应用程序时,它工作正常。 我想通过点击 BackButton 来做同样的事情。 有什么想法吗??
最佳答案
在此方法中输入您想要的任何代码:
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
super.onBackPressed();
}
教程在这里:http://chrisrisner.com/31-Days-of-Android--Day-10%E2%80%93The-Back-Button
关于android - 如何通过覆盖 BackButton 使我的 PhoneGap android 应用程序暂停?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11297763/