is it possible to store pending intent persistently somehow?
No.
is it possible to "get back" reference to the same pending intent I already got before?
Not from the OS. If you have some other "bootstrap" communications method, you could ask the original app to re-supply a PendingIntent
. For example, you could send a broadcast stating that you need apps to re-register; apps using your service would listen for such broadcasts and give you a fresh PendingIntent
.
Or, skip the PendingIntent
entirely and use something else. For example, apps could export a BroadcastReceiver
. Where they would register a PendingIntent
in your current plan, they would simply provide you the ComponentName
of the BroadcastReceiver
. That information (package name and class name) could be persisted, and you could then send a broadcast to that specific ComponentName
as needed.
Note that with any strategy that involves persistence, you will need to deal with the cases where the client app has been upgraded and the old stored details are now incorrect (e.g., they refactored their code, and the old ComponentName
is now invalid).