I have a receiver that start after phone boot like this:
<receiver android:name=".OnBootReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
in the receiver I run set an alarm like this:
AlarmManager mgr=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Intent i=new Intent(context, LocationPoller.class);
i.putExtra(LocationPoller.EXTRA_INTENT,
new Intent(context, LocationReceiver.class));
i.putExtra(LocationPoller.EXTRA_PROVIDER,
LocationManager.GPS_PROVIDER);
PendingIntent pi=PendingIntent.getBroadcast(context, 0, i, 0);
mgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.elapsedRealtime(),
PERIOD,
pi);
It works fine, except, of course, when user install app, the alarm will not be set until user reboot phone,.
to go around this, I need to check from my Activity if AlarmManager is set, if not I need to set from Activity.
Hence, how do I check if Alarm manager is already set.