How to show Dialog in onCreate method?

How to show Dialog in onCreate method? Is this possible at all, I tried, but I got an exception from the window. Can anyone suggest something for me?

+4
source share
2 answers

you can use the ProgressDialog class using the help of the Handler class. This way you can achieve what you want.

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(); } } 
+5
source

I am sure you can use a bad context. To display the UI(specific) Activity dialog box, do not use getApplicationContext() or getBaseContext() . Just create an instance using Activity_Name.this and you can show the Dialog.

+3
source

Source: https://habr.com/ru/post/1393946/


All Articles