How to work with progress dialog in Android c# apps?

soumenhaldersoumenhalder Member ✭✭
edited September 2018 in Xamarin.Android

How to work with progress dialog in Android c# apps? Here I am using below mentioned code but it is giving error while i am going to show ProgressDialog.

ERROR IS: Unhandled Exception:
Android.Views.WindowManagerBadTokenException: Timeout exceeded getting exception details

ProgressDialog progressDialog;       

        protected override void OnCreate(Bundle bundle)

            progressDialog = ProgressDialog.Show(this, "", "Loading Please wait...", false, true);
            progressDialog.Indeterminate = true;
            // My code below    

How to resolve this?

Best Answer


  • meepoumeepou FRMember ✭✭

    Please be aware that ProgressDialog is deprecated in API 26, use ProgressBar instead !

  • soumenhaldersoumenhalder Member ✭✭
    edited September 2018

    Hello @ChristopheBERNARD , the solution you have provided is perfect.
    But I am facing another problem here. Which is completely different.
    The scenario is, I have a Master activity which is implementing "TabActivity" class. The master has TabWidget with 4 tab TabSpec.
    Then it calls first activity where this ProgressDialog is being fired and it is facing error "Android.Views.WindowManagerBadTokenException" how to resolve this? please help.

    ProgressDialog is working in any other pages.

  • ChristopheBERNARDChristopheBERNARD BEMember ✭✭✭✭

    Hello @soumenhalder ...i don't know the best is to put a break point and see what happen's of course the object.Show make an exception but you nee do see if you context is present and on so ..

    I have found a similar question where the developer replace the progressDialog by an alertDialog ..
    Here is it the link

    try and tell us or make a little sample where i can reproduce your problem and i will try

  • hi @ChristopheBERNARD ,
    I call it from my master activity. And it is working as expected. Thank you for the support.

  • ChristopheBERNARDChristopheBERNARD BEMember ✭✭✭✭

    @soumenhalder you're the best

Sign In or Register to comment.