I'm facing a strange problem in my application, since I'm testing on 4 different devices but only two of them have the expected behavior.
Scenery / Devices:
- Nexus 4 / Android 5.0 - Ok
- Galaxy Tab 2 / Android 4.2.2 - Ok
- LG Optimus / Android 4.4.2 - Error
- Genesis / Android 4.1.2 - Error
As you can see, 4 different versions of Android and only the first two are working.
The problem in question is that the first time I install the application on the device, I run a task with AsyncTask
and everything happens normally. But from there I can not run it any more.
As the onPreExecute()
method still runs on the same thread, my debug arrives at it without problem, but not at doInBackground()
.
I read something about the executeOnExecutor()
method from API 11 (my application is from 15) but I do not think that's the case, since I do not want multiple tasks in parallel but a simple one.
The simple representation of my code is this:
new AsyncTask<Void, Void, Void>() {
@Override
protected void onPreExecute() {
// Preparo minha UI
super.onPreExecute();
}
@Override
protected Void doInBackground(Void... params) {
// Executo minha tarefa
return null;
}
@Override
protected void onPostExecute(Void result) {
// Conclusão
super.onPostExecute(result);
}
}.execute();
Anyway, I do not know what can be happening, I've researched a lot and found nothing. My development environment is Android Studio 1.0.1 , compiled with version 21 of the SDK.