Note that there are some explanatory texts on larger screens.

plurals
  1. POAysnc : doPostExceute() is getting even before doInBackground() in android
    primarykey
    data
    text
    <p>I am using <code>AsyncTask</code> to do background processing i.e I'm fetching the data from the server and storing in the <code>List</code> in <code>doInBackground()</code> method. I'm using this stored data in <code>onPostExecute()</code>. </p> <p>The problem that I'm facing is the <code>onPostExceute()</code> is getting executed even before <code>doInBackground()</code> is done it's execution.</p> <p>Can someone suggest what might be going wrong ?</p> <p>Code:</p> <pre><code>AsyncTask&lt;Void, Void, Void&gt; read= new AsyncTask&lt;Void, Void, Void&gt;() { ProgressDialog progress= new ProgressDialog(LastData.this); ArrayList&lt;String&gt; testData; DBAdapter db; @Override protected void onPreExecute() { // TODO Auto-generated method stub super.onPreExecute(); progress.setTitle("Please Wait"); testData= new ArrayList&lt;String&gt;(); db= new DBAdapter(LastData.this); progress.setProgressStyle(ProgressDialog.STYLE_SPINNER); progress.setMessage("Fetching Data !!"); progress.show(); } @Override protected Void doInBackground(Void... params) { // TODO Auto-generated method stub ParseQuery query = new ParseQuery("Details"); query.findInBackground(new FindCallback() { public void done(List&lt;ParseObject&gt; dataList, ParseException e) { if (e == null) { Log.d("Details", "Retrieved " + dataList.size() + " scores"); for (int idx = 0; idx &lt; dataList.size(); idx++) { data.add(dataList.get(idx).get("fname") .toString()); } } else { System.out.println(e.getMessage()); } for (int idx = 0; idx &lt; data.size(); idx++) { testData.add(data.get(idx)); } System.out.println("size inside is " + testData.size()); } }); return null; } @Override protected void onPostExecute(Void result) { // TODO Auto-generated method stub super.onPostExecute(result); progress.dismiss(); Toast.makeText(LastData.this, "Size is "+testData.size(), Toast.LENGTH_LONG).show(); } }; read.execute(); </code></pre> <p><code>Toast</code> meassage in <code>onPostExecute()</code> is getting displayed even before the <code>doInBackground</code> method is exceuted. </p>
    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