Progressdialog Not Showing Up In Activity
I am trying to include a ProgressDialog in my application. But it is not showing up. Here's the code snippet where i use the ProgressDialog: public class abcActivity extends Activi
Solution 1:
I think your code is wrong in a sense that you do all in the UI thread. You have to put callsomefunction() into a background thread.
publicvoidrunSomething()
{
showDialog(BACKGROUND_ID);
Thread t = new Thread(new Runnable()
{
publicvoidrun()
{
//do something
handler.post(finishThread);
}
});
t.start();
// The progress wheel will only show up once all code coming here has been executed
}
And as well
protected Dialog onCreateDialog(int id)
{
if(progressDialog == null) progressDialog = newProgressDialog(this);
return progressDialog;
}
@OverrideprotectedvoidonPrepareDialog(int id, Dialog dialog)
{
if(id == BACKGROUND_ID)
{
progressDialog.setIndeterminate(true);
progressDialog.setCancelable(false);
progressDialog.setMessage("running for long ...");
}
}
RunnablefinishThread=newRunnable()
{
publicvoidrun()
{
//long runningif(progressDialog != null) progressDialog.dismiss();
}
};
Solution 2:
i think issue is in your switch condition pls verify it.
here is another method to display dialog in android try this.
publicstaticfinalintDIALOG2_KEY=1;
publicstatic ProgressDialog dialog1;
showDialog(DIALOG2_KEY); // use it where you want to display dialog
dialog1.cancel(); // use it to cancel the dialog@Overridepublic Dialog onCreateDialog(int id) {
if (id == 1) {
dialog1 = newProgressDialog(this);
dialog1.setMessage("Please wait...");
dialog1.setIndeterminate(true);
dialog1.setCancelable(true);
}
return dialog1;
}
Solution 3:
Ensure you have this code called by debugging or adding a log. The code seems right to me.
Also, if you want to perform some operations in background and show a progress dialog while the performing, please use AsyncTask with ProgressDialog bounded, like here.
Solution 4:
ProgressDialog is deprecated in Android O , Use ProgressBar now.
Post a Comment for "Progressdialog Not Showing Up In Activity"