Hi I'm trying out using a progress dialog while I'm connecting to mysql database on a distance server, usually it takes about 1 second (approximatively) to register/create an account but I wanted to be sure I wasn't going to freeze the app ... So i've put a progressdialog and since the treatement are very fast I guess it doesn't show up ? Is that right ? Is there a minimum time for it to show up ?
Asked
Active
Viewed 454 times
0
-
Maybe it is just disappearing extremely fast. This should help you show it for a minimum time: https://stackoverflow.com/questions/9540854/progressdialog-only-shows-for-an-instant – Moshe Katz Sep 05 '17 at 01:13
1 Answers
0
You can start a processDialog in a thread.
private ProgressDialog progDialog;
String str_process = getResources().getString(R.string.str_process);
String str_wait = getResources().getString(R.string.str_wait);
progDialog = ProgressDialog.show(MyApp.this, str_process, str_wait);
new Thread() {
public void run() {
try{
//TOTO here, put your code here or sleep few seconds
}catch (Exception e){ }
handler.sendEmptyMessage(0);
progDialog.dismiss();
}
}.start();
private Handler handler = new Handler(){
@Override
public void handleMessage(Message msg){
}
};
May be help you.

neildd
- 41
- 4