public class Container {
public process(T result){
// Update UI
}
public anotherMethodThatUpdatesUI(T result){
// Update UI
}
public SomeTask extends AsyncTask<T,T,T> {
private Container container;
public someTask(Container container){
this.container = container;
}
protected void onPostExecute(T result) {
super.onPostExecute(result);
container.process(result);
}
}
}
I first call the AsyncTask
execute
method which works correctly. But after that calling anotherMethodThatUpdatesUI
fails with this exception:
Can't create handler inside thread that has not called Looper.prepare()
But if I remove the refrence to Container
inside the AsyncTask
and call process
directly. I don't get the error.
public SomeTask extends AsyncTask<T,T,T> {
private Container container;
public someTask(Container container){
// this.container = container;
}
protected void onPostExecute(T result) {
super.onPostExecute(result);
process(result);
}
}