The question is more conceptual than coding-related.
I have an app with Activity
A and B.
I call an AsyncTask
from Activity
A, while the call is being made, I don't want to block the user showing the progressdialog, so my user can freely move around the application without getting bored of waiting.
Now, the query is AsyncTask
or lets say a Service
is being called from Activity
A which is responsible for downloading some kind of data from the server. While the call is being made, the user has changed the Activity
and Activity
A has gone to background.
Now, while the user is freely moving around the application, he just wants to come back to Activity
A to check the download status,(which is something lets say I set some data to my TextView
).
Now the question is, once the download is over , while my Activity
A is still in background, my UI should be updated while Activity
is still in background. This way the user feels he gets the data before he switches to Activity
A.
Is this possible, if so how?
Summarizing my question, can I update the UI of an Activity
while it is still in background with the Asynctask
or Service
which the Activity
invoked to fetch data from server.
One post suggested that ideally I need to update the **UI in onResume()
. My question is, is this the only approach?
once the download is over , while my
Activity
A is still in background, my UI should be updated whileActivity
is still in background. This way the user feels he gets the data before he switches toActivity
A.
It isn't possible. You see, the Activity
has to pass through the onCreate()
and onResume()
callbacks for the UI to be changed.
Also, you should be using a bound Service
to update the Activity
when it returns to the foreground.
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