[Edit] Just to make it shorter. I know how to update progressDialog from within the doInBackground. I'm looking for a way to update the progress from a different class while the Async class stays in the main activity. [Edit]
In my main activity I have several buttons, each executing a different AsyncTask. Because I want to keep my code nice I want to perform the doInBackground stuff in a different class, something like this:
Main activity
@Override
protected ArrayList<Object> doInBackground(String... params) {
String query = params[0];
return OtherClass.performSomethingThatTakesTime(query);
}
@Override
protected void onPostExecute(final Object result) {
runOnUiThread(new Runnable() {
@Override
public void run() {
sendIntentToAnotherClass(result);
}
});
}
At this timeI have the entire OtherClass.performSomethingThatTakesTime(query)
inside the doInBackground and I update the progress through the code using publishProgress(value)
.
But like I said I'd prefer to have the code in a different class but can I update the progress on UI from a different class?