Android App Crash when navigate Back

DeepikaAgnihotriDeepikaAgnihotri ✭✭INUniversity ✭✭

I am using IUserDialogs UserDialogService.Toast(message) to display toast message in my Android application, As Toast's default value is 3 sec to timeout from view, If i am trying to navigate back to previous activity while toast is still displaying and timeout not completed. App get crash with below message:

Java.Lang.IllegalArgumentException:$DecorView{41cc56f8 G.E..... R.....I. 0,0-434,77} not attached to window manager

Can anyone help me to resolve this, i want to do manual timeout or dismiss toast before navigate back to previous activity. I tried doind that in OnDestroy but not worked.

Deepak Agarwal


  • rene_ruppertrene_ruppert Xamurai DEXamarin Team, University, XamUProfessors Xamurai

    Can you please provide more information about the code/component you are using IUserDialogs is not a Xamarin component AFAIK. A self contained example showing the problem would also be helpful.
    If this is a third party component/library, you might also consider contacting the author directly or (if it's hosted on Github) submit an issue.

  • DeepikaAgnihotriDeepikaAgnihotri ✭✭ INUniversity ✭✭

    Yes it's from Acr.UserDialogs Library. Below is the Acr IUserDialogs Toast method, which i am using in my class:

    void Toast(string message, int timeoutSeconds = 3, Action onClick = null, MaskType maskType = MaskType.None);

  • GlennStephens.8241GlennStephens.8241 Xamurai AUXamarin Team, University, XamUProfessors, Developer Group Leader Xamurai

    Hi Deepak,

    You would probably need to hide the dialog if it is already present. The Destroy is probably not the best place for it. I would try looking at the OnPause method as another option.

    As it is a third-party component; I would also echo René's comment that you should contact the author of the component. Chances are there are particular conventions that the component requires.

  • AllanRitchieAllanRitchie ✭✭✭ CAInsider, University ✭✭✭

    @DeepikaAgnihotri why don't you report these things on the github repo in the future? That way, I know about them and can possibly fix or assist you with them.

    As of v6.1, you can dispose of a toast in code regardless of the timer. In this case,
    var disposable = UserDialogs.Instance.Toast("Hi"); // signatures have changed disposable.Dispose(); // whenever you need it to go away - OnPause is the best place to do this

Sign In or Register to comment.