Issue
I create a ProgressDialog in my onStart and then later on, after an async task returns, I hide/dismiss it.
When I jump to the homescreen and back, and re-instantiate a new ProgressDialog to the variable, the code later on still references the old memory address of the last time I set ProgressDialog.
I have tried a multitude of different approaches but I'm stumped. I can't seem to get a ProgressDialog to behave properly after the first start of the app. Could someone guide me in how to fix this, or suggest a different approach?
Thanks.
EDIT: I should mention that I tried using the same variable I set initially, instead of re-instantiating it, but hide/dismiss did nothing.
In onStart()
mProgressDialog = new ProgressDialog(this);
mProgressDialog.show();
Then later in my updateMap()
mProgressDialog.dismiss(); // Or hide()
This works fine the first run. But when the activity is stopped and restarted, the second block does not execute as expected.
EDIT 2:
private ProgressDialog mProgressDialog;
onCreate()
mProgressDialog = new ProgressDialog(this);
onResume()
mProgressDialog.show();
updateMap()
mProgressDialog.hide();
It works the first run, but when the I jump to the homescreen and back, the ProgressDialog never hides. What's going on?!
Solution
Try setting the ProgressDialog variable to static. When the activity is recreated, it should reference the same ProgressDialog attached to that activity class, rather than a new one in a new instance of the class.
Answered By - Nick
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.