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?
LocalBroadcastManager is an application-wide event bus and embraces layer violations in your app: any component may listen events from any other.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With