Note that there are some explanatory texts on larger screens.

plurals
  1. POonPostExecute() is waiting too long?
    primarykey
    data
    text
    <p>I have some control and for this reason i did some threads.I want to show loading bar one screen to another screen with asycntask.My problem is Loading bar is showing and disapper quickly and then waiting for the same screen alot without loading bar.And after for a while it is going second screen. I think post execute is not working for me correctly.Can anybody help me?</p> <p>This is my code: </p> <pre><code>private class ProgressBarAsync extends AsyncTask&lt;Void, Integer, Void&gt;{ /** This callback method is invoked, before starting the background process */ @Override protected void onPreExecute() { super.onPreExecute(); /** Creating a progress dialog window */ mProgressDialog = new ProgressDialog(Login.this); /** Close the dialog window on pressing back button */ mProgressDialog.setCancelable(true); /** Setting a horizontal style progress bar */ mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); /** Setting a message for this progress dialog * Use the method setTitle(), for setting a title * for the dialog window * */ mProgressDialog = ProgressDialog.show(Login.this, "Giriş yapıyorsunuz", "Lütfen bekleyin..."); } /** This callback method is invoked on calling execute() method * on an instance of this class */ @Override protected Void doInBackground(Void...params) { try { startMyApplication() ; } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } /** This callback method is invoked when publishProgress() * method is called */ @Override protected void onProgressUpdate(Integer... values) { super.onProgressUpdate(values); mProgressDialog.setProgress(mProgressStatus); } /** This callback method is invoked when the background function * doInBackground() is executed completely */ @Override protected void onPostExecute(Void result) { super.onPostExecute(result); if (mid &gt; 0) { Intent btn_login = new Intent( getApplicationContext(), MainScreen.class); startActivity(btn_login); } else { AlertDialog.Builder alertDialog = new AlertDialog.Builder(Login.this); // Setting Dialog Title alertDialog.setTitle("GİRİŞ"); // Setting Dialog Message alertDialog.setMessage("Kullanıcı adı veya Parola Hatalı Lütfen tekrar deneyin."); // Setting Icon to Dialog //alertDialog.setIcon(R.drawable.delete); // Setting Negative "NO" Button alertDialog.setNegativeButton("TAMAM", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); // Showing Alert Message alertDialog.show(); } //run(); mProgressDialog.dismiss(); </code></pre> <p>This is startmyapp theads:</p> <pre><code>public void startMyApplication() throws InterruptedException { ExecutorService executor = Executors.newFixedThreadPool(2); FutureTask&lt;String&gt; futureOne = new FutureTask&lt;String&gt;( new Callable&lt;String&gt;() { public String call() throws Exception { if (isOnline()) { // Call Login Web Service with username and password and get mid mid = callLoginWS(username.getText().toString(), password.getText().toString()); if (mid &gt; 0) { //callPasswordGeneratorWS(mid); // Insert mid and username into sqllite dbInstance.insertMerch(mid,username.getText().toString()); } Log.i("futureone", "futureone"); } return "TEST"; } }); FutureTask&lt;String&gt; futureTwo = new FutureTask&lt;String&gt;( new Callable&lt;String&gt;() { public String call() throws Exception { // Get mid from database mid = dbInstance.selectMerch(username.getText().toString()); return "TEST"; } }); // ... Dispatch // Check if user exists previously // ... Dispatch mid = dbInstance.selectMerch(username.getText().toString()); dbInstance.close(); executor.execute(futureOne); while (!(futureOne.isDone())) { executor.execute(futureTwo); } Log.i("login","new login"); //} executor.shutdown(); } </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