Hi stackoverflow community. This is my first time asking a question so please forgive me if I have some errors in this post
I am trying to communicate an Activity with an Intent Service using the Result Receiver pattern explained in this post and discussed here in stackoverflow. Eveything is working OK in a sample app but I am not sure if this pattern is effective when Activity goes to background or gets killed by Android OS.
Basically, what I want to achieve is the following app behavior:
- Activity: Starts IntentService to do some work. Passes ResultReceiver to receive progress updates
- IntentService: Starts working, get Activity's ResultReceiver.
- IntentService: Work is completed in 10%, notifies Activity by sending message to Result Receiver
- Activity: Receives message in onReceiveResult
- IntentService: Work is completed in 40%, notifies Activity by sending message to Result Receiver
- Activity: Receives message in onReceiveResult
- At this point, user goes to another app. Activity goes to background dettaching first the Result Receiver. Android OS could also have destroyed this Activity because of an incomming call
- Intent Service: Work complete. Tries to notify Activity but no Result Receiver available. Saves message for later redelivery to Activity.
- At this point, user gets back to the app. Activity goes to foreground, attaches Result Receiver and gets pending message from Intent Service that notifies that work is done.
So, my question is how to handle pending notifications of an IntentService to the Activity using the Result Receiver pattern?
Thank you very much.