0

I'm using a progressDialog in AsyncTask but it is not showing the progressDialog and it is also skipping frames. Here is the log:

05-09 00:09:41.958: E/pass 1(16031): Connection success 
05-09 00:09:41.968: E/pass 2(16031): Result: Success!
05-09 00:09:41.978: I/System.out(16031): Out background...
05-09 00:09:41.978: I/Choreographer(16031): Skipped 56 frames!  The application may be doing too much work on its main thread.
05-09 00:09:42.008: I/System.out(16031): In onPostExecute...
05-09 00:09:42.018: I/System.out(16031): Committed.
05-09 00:09:42.018: I/System.out(16031): Out onPostExecute...

And here is the code:

protected void onPreExecute() {
    progressDialog = ProgressDialog.show(NewNote.this, "", "");
    progressDialog.setCancelable(false);
    progressDialog.setContentView(R.layout.progressdialog);
    progressDialog.show();
}

protected Void doInBackground(Void... params) {
   System.out.println("In background...");
   //connecting to the internet and saving the shared preference
   System.out.println("Out background...");
        return null;
}

protected void onPostExecute(Void result) {
    System.out.println("In onPostExecute...");
    progressDialog.dismiss();
    System.out.println("Committed.");
    setResult(RESULT_OK, data);
    finish();
    System.out.println("Out onPostExecute...");
}

Why is the progressDialog not showing?

Thanks.

GabrielOshiro
  • 7,986
  • 4
  • 45
  • 57
MosesA
  • 925
  • 5
  • 27
  • 53

1 Answers1

2

When using an AsyncTask, you should not call get() as get() runs the doInBackground() on the current thread (most likely your main thread), causing your UI to freeze.

ianhanniballake
  • 191,609
  • 30
  • 470
  • 443