Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show Dialog in onCreate method?

How to show Dialog in onCreate method ? Is that possible at all, I tried but I got leaked window exception. Can anyone suggest me anything ?

like image 752
Damir Avatar asked Jan 31 '12 10:01

Damir


2 Answers

you can use ProgressDialog Class with the Help of Handler Class. This way you can achieve what you want to do.

progDailog = ProgressDialog.show(loginAct,"Process ", "please wait....",true,true);

new Thread ( new Runnable()
{
     public void run()
     {
      // your loading code goes here
     }
}).start();


     Handler progressHandler = new Handler() 
     {

         public void handleMessage(Message msg1) 
         {

             progDailog.dismiss();
             }
     }
like image 165
Lucifer Avatar answered Oct 07 '22 18:10

Lucifer


I am sure that you might be using a bad context there. To show the Dialog on the UI(specific) Activity don't use getApplicationContext() or getBaseContext(). Just create the instance using Activity_Name.this and you will be able to show the Dialog.

like image 23
Lalit Poptani Avatar answered Oct 07 '22 17:10

Lalit Poptani