1

I've built an app that was working fine and has been tested on multiple devices (about 20 different ones), but now android 4.4.2 users (1 nexus tablet and 3 HTC One phones) are reporting issues.

I have traced the problem and found that onPreExecute and onPostExecute are not being called on these devices.

My code looks (simplified) like this:

public class MyTask extends AsyncTask<Void, Void, Boolean> {

    /** [...] **/


    @Override
    protected void onPreExecute() {
        Log.d(TAG, "onPreExecute executed");
    /** [...] **/
    };

    @Override
    protected Boolean doInBackground(Void... arg0) {
        Log.d(TAG, "Task running in background");
        return client.loadUrl();
    }

    @Override
    protected void onPostExecute(Boolean isOpen) {
        Log.d(TAG, "onPostExecute executed");
    /** [...] **/
    }
}

I'm running the task calling the execute() method.

Like I said: I can see in the logs that the 'Task is running in the background', but only on the 4.4.2 devices I notice that the log-lines of the onPre- and onPostExecute are missing.

Does someone know if this behaviour has changed? I couldn't find anything about it in the documentation.

Or better: does someone know how to fix this?

Rob Kielty
  • 7,958
  • 8
  • 39
  • 51
marty
  • 61
  • 1
  • 6
  • 1
    Can you post the complete code please ? The call to the AsyncTask & the full AsyncTask. Because there is an issue on your onPostExecute declaration. (the ") – Andros Apr 18 '14 at 13:58
  • check http://stackoverflow.com/questions/7211684/asynctask-executeonexecutor-before-api-level-11 – Amit Apr 18 '14 at 14:54
  • I cannot explain why it wasn't showing the onpre/onpostexecute logs. I haven not been able to reproduce that the next day. In the end, what was executed in the onpostexecute simply didn't work because of this bug : https://code.google.com/p/android/issues/detail?id=68895 – marty Apr 27 '14 at 19:46

0 Answers0