I have an AsyncTask in my program that seems to stop after onPreExecute(), after the app is run several times. What I mean is, I can use the app and everything works about 10-20 runs, but then it halts. Here is what’s going on:
private class MyTask extends AsyncTask<String, Void, Data> {
protected void onPreExecute() {
// show loading dialog
Log.d(TAG, "end onPreExecute");
}
protected Data doInBackground(String... params) {
Log.d(TAG, "start doInBackground");
// do stuff
}
protected void onPostExecute(Data myData) {
// do stuff
}
}
When it stops working, what happens is that the loading dialog just keeps loading forever, and "end onPreExecute" prints but "start doInBackground" does not.
Why might that be?
It’s hard to tell where the problem is. As your Async Task seems to work the first couple of times, it could be that this API-feature is just too “unstable” for your intention…
A solution for your issue could simply be, to replace the AsyncTask by a different Thread solution:
Hope that helps!