The documentation says that execute() must be called from a UI thread. But, since I am updating images every few seconds, I am using a Runnable. And in that, I define the operations that have to be executed. Starting(execute())ASyncTask is one of them. But, since ASyncTask is not supposed to be called from anything but the UI thread, how do I proceed?
just add runOnUiThread in Runnable for starting AsyncTask :
private Runnable updateImages= new Runnable() {
public void run() {
runOnUiThread(new Runnable() {
public void run() {
// call your asynctask here
}
}
});
//////YOUR CODE HERE
}
Possibly redesign your project to work with only AsyncTasks rather than a Runnable. I'm not sure how AsyncTask likes this behavior as well, but I have changed some UI stuff in AsyncTasks before.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With