Sunday, 18 August 2013

How to update Activity's variable during AsyncTask?

How to update Activity's variable during AsyncTask?

I'm trying to update a variable from AsyncTask, but I'm not exactly sure
how. This is what I tried:
Outside the AsyncTask is the activity class that has a variable..:
int myVariable = 0;
class MyTask extends AsyncTask<Void, Void, Void> {
protected Void doInBackground(Void... args0) {
myVariable = 3;
return null;
}
}
When i print out the variable, it still says 0, and not 3. I'm using
AsynTask for something more complicated, but this is the dumbed down
version of what I'm trying to accomplish.

No comments:

Post a Comment