Take the 2-minute tour ×  My application shows content for a
site that also has a notification system. I want to show if
there are new notifications, and I am using an AlarmManager that
calls an IntentService.  My question is: where should I
start/register this AlarmManager? I've put it in the onCreate()
of my activity just for proof-of-concept (and its working fine,
thank you very much :) ), but if you would start that activity
twice, you would get multiple alarms.  The only possible
solution I've come up with is this, but I don't know if this
would be best practice    • Start the manager in an onCreate()
if the preference "alarm started" is false   • Set some variable
that it is started in preferences.  Now if the alarm stops for
some reason, there's no way to restart it. So, a variation would
be:    • Always call cancel in the onCreate()   • And then
always set the Alarm.  This seems like a common pattern: Wanting
to periodically get information with an alarm, and not setting
that alarm more then once. How