I have used AsyncTasks
with my application, in order to lazy download and update the UI.
For now my AsyncTasks
updates the UI real simply:
Even though, I have never faced this scenario; I will try to answer your question.
In your case you will need to validate the Context
passed to AsyncTask
.
You can perform validation
if(null!=mContext) //Activity still exist!!
{
gender.setText(values[0]);
}
else //Activity is destroyed
{
//Take appropriate action!!
}
The advantage will be, if the activity is destroyed by the time you reach this statement, your Context
will automatically become null
and you can handle the scenario.