The title isn't good, please read bellow to understand better my problem
I have an Android application, one of its tasks is time consuming and will often take between 2-5 minutes to be finished... this task is done by a background service which has a reference to the starter activity.
99% of users doesn't want to wait all this time looking to a loading bar and will simple open another app or something like... what might lead to android destroying
the referenced activity...
Ignoring the context leak of this story... my problem is:
When the service finishes its task it will try to call a method to return the values to the parent activity, but as it was destroyed now I can't do it...
So when user re-opens the app the last known state by that activity is "loading" so it keeps loading forever... (or retry to rerun the task what will lead to another 5 minutes wait and so on...)
how can i avoid this situation?
==============update=================
After getting a very good answer that would probably solve most of problems like mine i decided to add more information to let clear my problem.
The time consuming background service ISN'T process intensive, actually the reason it takes so long is because it is validating with the service some user "credentials" (when i say some, is really more than one)
So i can't store the result and trust it is valid on next run
I do know the this protocol needs to be improved but is going to take a bigger archtecture change so i would like to know if someone has any idea how to handle it on its actual requirements