I have a data object which occasionally gets refreshed from a data source on the web using a recurring alarm.
This data object has keeps track of objects which want to be notified when it gets new data. I currently use two means to register listeners - they can register either as a callback if they expect to be refreshed only while the app is in the foreground, or they can register with a PendingIntent
if the observing object needs to be notified even if the app is not active.
My problem is that if my data object gets removed from memory, then its list of PendingIntents is also removed. I suppose I could come up with a complicated method of persisting the list and all of the fields in it in shared preferences or something, but I think that there just has to be a better way.
Is there a way that I can ask the system, which I know holds its own list of PendingIntents, for all of "my" PendingIntents?
Note that I cannot re-create the PendingIntents when I create the object or at any other time - the are created by the listeners, and there is no way to deduce what fields they have set or their values.