我如何创建 运行 应用程序甚至用户关闭它 android
how can i create run app even user close it android
想为 android 创建应用程序 cordova 和 ionic 以在某些时候像 2:50 报警,我想要程序 运行 甚至关闭程序
我使用 katzer/cordova-plugin-background-mode 插件,但是当我关闭程序时,它关闭并且不在后台 运行 这是代码
// Run when the device is ready
document.addEventListener('deviceready', function () {
// Android customization
// To indicate that the app is executing tasks in background and being paused would disrupt the user.
// The plug-in has to create a notification while in background - like a download progress bar.
cordova.plugins.backgroundMode.setDefaults({
title: 'TheTitleOfYourProcess',
text: 'Executing background tasks.'
});
// Enable background mode
cordova.plugins.backgroundMode.enable();
// Called when background mode has been activated
cordova.plugins.backgroundMode.onactivate = function () {
// Set an interval of 3 seconds (3000 milliseconds)
setInterval(function () {
var dd = new date();
var h = dd.getHours();
var m = dd.getMinutes();
if(h == 2 && m ==50){
alert("2:50");
}
}, 3000);
}
}, false);
如何让应用程序仍然运行即使用户关闭程序,如闹钟或某些程序提醒?
你试过了吗:
http://developer.android.com/guide/components/services.html
这可能会有帮助
想为 android 创建应用程序 cordova 和 ionic 以在某些时候像 2:50 报警,我想要程序 运行 甚至关闭程序 我使用 katzer/cordova-plugin-background-mode 插件,但是当我关闭程序时,它关闭并且不在后台 运行 这是代码
// Run when the device is ready
document.addEventListener('deviceready', function () {
// Android customization
// To indicate that the app is executing tasks in background and being paused would disrupt the user.
// The plug-in has to create a notification while in background - like a download progress bar.
cordova.plugins.backgroundMode.setDefaults({
title: 'TheTitleOfYourProcess',
text: 'Executing background tasks.'
});
// Enable background mode
cordova.plugins.backgroundMode.enable();
// Called when background mode has been activated
cordova.plugins.backgroundMode.onactivate = function () {
// Set an interval of 3 seconds (3000 milliseconds)
setInterval(function () {
var dd = new date();
var h = dd.getHours();
var m = dd.getMinutes();
if(h == 2 && m ==50){
alert("2:50");
}
}, 3000);
}
}, false);
如何让应用程序仍然运行即使用户关闭程序,如闹钟或某些程序提醒?
你试过了吗:
http://developer.android.com/guide/components/services.html
这可能会有帮助