Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue with AsyncTask, when the onPostExecute is called?
    primarykey
    data
    text
    <p>I'm having a problem with OnPOstExecute of an AsyncTask, it works perfectly, but if the application some how stop, then a msg that generate a notification that opens the Activity that runs the AsyncTask, but the OnPOstExecute is never called.</p> <p>My doubt is: why OnPOstExecute doesn't work when I try to open the Activity from a Notification if the application is closed.</p> <p>Code:</p> <pre><code> protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ... ... try{ loadListTask = new LoadListTask(); loadListTask.execute(); }catch(Exception e){ Log.d(TAG,"ERRO: "+e.getMessage()); } } public void loadListView() { messagesDb = useful.buscarMessagesDb(this); ArrayList&lt;Message&gt; messageListViews = new ArrayList&lt;Message&gt;(); int messagesDbSize = messagesDb.size(); for (int i = 0; i &lt; messagesDbSize; i++) { if (((messagesDb.get(i).idFrom == myId) &amp;&amp; (messagesDb.get(i).idTo == idContact)) || ((messagesDb.get(i).idFrom == idContact) &amp;&amp; (messagesDb.get(i).idTo == myId))) { Message message = new Message(messagesDb.get(i).idFrom, messagesDb.get(i).idTo, messagesDb.get(i).dt, messagesDb.get(i).mensagem, messagesDb.get(i).confirm, messagesDb.get(i).idWeb); messageListViews.add(message); } else { //Log.d(TAG, "Essa mensagem não é pra esse contato!!!"); } } listChat.setAdapter(null); pref.edit().putBoolean("isUpdate", false).commit(); AdapterMessageListView adapterMessageListView = new AdapterMessageListView(myId, idContact, getApplicationContext(), messageListViews); listChat.setAdapter(adapterMessageListView); listChat.setCacheColorHint(Color.TRANSPARENT); listChat.setSelection(listChat.getCount()); } private class LoadListTask extends AsyncTask&lt;Void, Void, String&gt; { @Override protected String doInBackground(Void... params) { try { Log.d(TAG,"doInBackground"); Thread.sleep(100); } catch (InterruptedException e) { } return "list"; } @Override public void onPreExecute() { Log.d(TAG,"PREEXECUTE"); } @Override protected void onPostExecute(String result) { Log.d(TAG,"PostExecute"); loadListView(); loadListTask = new LoadListTask(); loadListTask.execute(); super.onPostExecute(result); } } </code></pre> <p>Message:</p> <pre><code>02-25 14:05:42.396: D/Chat(20663): doInBackground 02-25 14:05:42.396: W/MessageQueue(20663): Handler{40532ad8} sending message to a Handler on a dead thread 02-25 14:05:42.396: W/MessageQueue(20663): java.lang.RuntimeException: Handler{40532ad8} sending message to a Handler on a dead thread </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload