Progress Dialog returns to home screen

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Progress Dialog returns to home screen

Postby borya » Thu Jul 10, 2008 12:50 am

Hi guys,
For some reason when I call my progress dialog with
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. mProgressDialog = ProgressDialog.show(main.this, "Please wait...", "Logging in...", true);
  3.  
  4.                 handler = new Handler();
  5.  
  6.  
  7.  
  8.                 new Thread() {
  9.  
  10.                         public void run() {
  11.  
  12.                                 try{
  13.  
  14.                                         //do work
  15.  
  16.                                 } catch (Exception e) {  }
  17.  
  18.                                 // Dismiss the Dialog
  19.  
  20.                                 handler.post(new Runnable(){public void run(){mProgressDialog.dismiss();}});
  21.  
  22.                         }
  23.  
  24.                 }.start();
  25.  
  26.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4

as shown in the progressdialog tutorial here at anddev, it starts to try and render my UI (list activity) then boots me out to the home screen, shows the progress dialog then returns to the UI and shows all of the list elements. I've tried moving the place where I set my list adapter around to be either before or after this, but nothing has yielded a different result. Has anyone run into/know of a reason why this could happen?

Thanks in advance for the help! :)
borya
Developer
Developer
 
Posts: 27
Joined: Wed Jul 02, 2008 7:50 pm
Location: California, USA

Top

Postby borya » Thu Jul 10, 2008 7:08 pm

After playing around with it, I have discovered that the problem lies in the fact that I am calling the progress dialog from onCreate(). I attached the same code to a button, and it did not boot me out to the home screen. I still want it to run during onCreate() because the expensive operation inside it should happen when the activity is started. I am just adding this for extra information so that it can hopefully make my problem clearer.
borya
Developer
Developer
 
Posts: 27
Joined: Wed Jul 02, 2008 7:50 pm
Location: California, USA

Postby Jesmiatka » Fri Jul 11, 2008 7:46 am

I think the problem is that you call the ProgressDialog BEFORE you've set the content view. This means that the activity only has a ProgressDialog to show and no content (yet), because it is waiting for the progressdialog to finish.

Greetz,
Mike
Jesmiatka
Senior Developer
Senior Developer
 
Posts: 164
Joined: Mon Feb 04, 2008 3:37 pm
Location: Netherlands

Postby borya » Fri Jul 11, 2008 6:11 pm

Thanks for the help Mike,
But unfortunately I set my content view before I show the ProgressDialog. I have all of my code that sets the content view, initializes the content view, sets the array adapter, etc... before the call to the thread, in fact it is the last thing that happens in onCreate(). Do you know of any other reason it would behave that way?
Thanks,
Boris
borya
Developer
Developer
 
Posts: 27
Joined: Wed Jul 02, 2008 7:50 pm
Location: California, USA

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Majestic-12 [Bot] and 5 guests