Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make an alarm live even when the application which set it is killed?
    primarykey
    data
    text
    <p>I have a little confusion with setting an alarm. If anyone could give feedback or some hints it'll be greatly appreciated. In summary here is my situation:</p> <p>Inside my application I set an alarm:</p> <pre><code>//////////////////////// // Set an alarm // Actually I set a unique id here. The hardcoded value is for simplicity only. int id = 123454321; Intent intent = new Intent(context, MyAlarm.class); PendingIntent sender = PendingIntent.getBroadcast(context, id, intent, 0); long firstTime = SystemClock.elapsedRealtime(); firstTime += 10*1000; AlarmManager am = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstTime, 15*1000, sender); //////////////////////// //////////////////////// // MyAlarm implementation public class MyAlarm extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { // Do some periodic work here } } //////////////////////// </code></pre> <p>When I set the alarm everything is fine and good. I can see my alarm when I use the command:</p> <pre><code> adb shell dumpsys alarm </code></pre> <p>I can see the alarm even when my application goes to the background.</p> <p>Next I manually kill my application through </p> <p>Settings - Applications - Manage applications - - Force stop</p> <p>When I re-issue the command "adb shell dumpsys alarm" I see that my alarm is gone. This makes me think that when my application goes into the background and the framework kills it to free resources, my alarm will also be killed. However, I would like to have an alarm which will live independent of whether the application is running or not. Does anybody have hints how to do this? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload