Xamarin.Android: Showing ProgressDialog not working on Android 4.4.2

226 Views Asked by At

While developing I used to test and debug my application on my smartphone with android version 6.0. As far as the most code was written down and the app looks fine on my smartphone I wanted to try it on my Samsung Tablet with Android 4.4.2. Everything was fine, except the progressDialog. Logcat shows no error, the app doesn't close it just skips the rest of the current method.

Her my code:

void AnyMethod()
{
    var waitingDialog = new ProgressDialog(Application.Context);
    waitingDialog.SetProgressStyle(ProgressDialogStyle.Spinner);
    waitingDialog.SetMessage("Loading..");
    waitingDialog.SetCancelable(false);
    waitingDialog.Show();
    ..
    //do any other stuff 
}

Has anybody an idea how I can show a ProgressDialog in Xamarin.Android for version 4.0 an above?

1

There are 1 best solutions below

0
On

Because the problem is in this line.

var waitingDialog = new ProgressDialog(Application.Context);

If you are creating ProgressDialog in Activity then you can use this way

var waitingDialog = new ProgressDialog(this);

and if you are using in Fragement then use this way

var waitingDialog = new ProgressDialog(Activity);