android - Is it possible to do a repeated task even if app is killed from Task Manager? -


i've created alarmmanager call broadcastreceiver make request server every interval seconds.

alarmmanager alarmmanager = (alarmmanager) getsystemservice(context.alarm_service); pendingintent intent = pendingintent.getbroadcast(this, 0, new intent(this, sendlogreceiver.class), 0); alarmmanager.setinexactrepeating(alarmmanager.rtc_wakeup, system.currenttimemillis(), 1000, intent); 

and broadcastreceiver:

public class sendlogreceiver extends broadcastreceiver {     private static final string tag = sendpositionreceiver.class.getsimplename();      @override     public void onreceive(context context, intent intent) {         log.d(tag, "sending position server");     } } 

it works when app in background, when close app though task manager (by swiping) alarmmanager dies , no more signals received.

is there way achieve broadcastreceiver continue working whenever apps killed?

thanks

i not know "task manager" referring to.

the standard android recent-tasks list, , third-party task managers play store, not affect scheduled alarms.

there appear devices, device manufacturer has pre-installed separate "task manager" app, app equivalent of "force stop" ordinarily can button in app's page in settings. if user "force stops" app, alarms unscheduled, , app not run again until user manually runs home screen launcher. there nothing can that, though welcome complain device manufacturer developers idiots making "force stop" easy do.

you can use adb shell dumpsys alarm command determine whether or not alarm unscheduled.

bear in mind on android 5.1, polling period of 1000ms not supported. less 60000ms rounded 60000ms.

also bear in mind on android m, your app not run in background anyway. consider use of alarmmanager "nice have" sort of capability, rather can rely upon.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -