In one of my activities I\'m using AsyncTask. In doInBackground() I\'m making calls to various methods. In one of these methods I\'m getting an exc
If you have to declare anything related to Thread, then it must be outside the runOnUiThread() method, then only it is going to execute,
@Override
protected String doInBackground(String... strings) {
for(int i=0; i<10; i++) {
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(getApplicationContext(), "Example for Toast "+i, Toast.LENGTH_SHORT).show();
}
});
try {
Thread.sleep(10);
} catch (Exception e) {}
}
return "";
}