Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can i use AlarmManager with LocalBroadcastManager on android?

I've got this code:

private AlarmManager alarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
private PendingIntent alarmIntent = PendingIntent.getBroadcast(this, 0, new Intent("my action-name"), 0);

alarmManager.setInexactRepeating((int)AlarmManager.ELAPSED_REALTIME_WAKEUP,     SystemClock.elapsedRealtime() + autoUpdateIntervalInMinutes * 60 * 1000,  autoUpdateIntervalInMinutes * 60 * 1000, alarmIntent);

But I would like to change this for LocalBroadcastManager. Is this possible?

like image 416
Bartłomiej Mucha Avatar asked Aug 24 '12 16:08

Bartłomiej Mucha


People also ask

What is LocalBroadcastManager in android?

LocalBroadcastManager is an application-wide event bus and embraces layer violations in your app: any component may listen events from any other.


1 Answers

No, it is not possible, because LocalBroadcastManager is only for your own process, and AlarmManager's backend runs in a different process. That is why there is no way to create a PendingIntent that works with LocalBroadcastManager.

like image 56
CommonsWare Avatar answered Sep 30 '22 02:09

CommonsWare