Unable to add window -- token android. OS. BinderProxy,

Source: Internet
Author: User

Unable to add window -- token android. OS. BinderProxy,

Today, a program exception information is collected on google play.

Android. view. WindowManager $ BadTokenException: Unable to add window -- tokenandroid. OS. BinderProxy @ 406ab4c8is not valid; is your activity running?

At android. view. ViewRoot. setView (ViewRoot. java: 532)

At android. view. WindowManagerImpl. addView (WindowManagerImpl. java: 200)

At android. view. WindowManagerImpl. addView (WindowManagerImpl. java: 114)

At android. view. Window $ LocalWindowManager. addView (Window. java: 424)

At android. app. Dialog. show (Dialog. java: 241)

At android. app. AlertDialog $ Builder. show (AlertDialog. java: 802)

At com. nttdocomo. communicase. carriermail. activity. MailSettingAccountRecieveActivity $2 $ 1.run( MailSettingAccountRecieveActivity. java: 558)

At android. OS. Handler. handleCallback (Handler. java: 587)

At android. OS. Handler. dispatchMessage (Handler. java: 92)

At android. OS. lorule. loop (lorule. java: 130)

At android. app. ActivityThread. main (ActivityThread. java: 3687)

At java. lang. reflect. Method. invokeNative (Native Method)

At java. lang. reflect. Method. invoke (Method. java: 507)

At com. android. internal. OS. ZygoteInit $ MethodAndArgsCaller. run (ZygoteInit. java: 842)

At com. android. internal. OS. ZygoteInit. main (ZygoteInit. java: 600)

At dalvik. system. NativeStart. main (Native Method)

When dialog is displayed in the thread

[Java] view plaincopy

MailSettingAccountRecieveActivity. this)

GetString (R. string. check_failed_title ))

. SetPositiveButton (getString (R. string. OK), null)

});

The explanation on stackflow is:

The problem is that the dialog need to have the "base" context of your activity, not necessarily the one you're launching it from.

Then I added this code before the dialog.

NewAlertDialog. Builder (

. SetTitle (

. SetMessage (errMessage)

. Show ();

}

[Java] view plaincopy

}

. SetMessage (errMessage)

Activityactivity = MailSettingAccountRecieveActivity. this;

While (activity. getParent ()! = Null ){

Activity = activity. getParent ();

NewAlertDialog. Builder (activity)

. SetTitle (

GetString (R. string. check_failed_title ))

. SetPositiveButton (

GetString (R. string. OK ),

Null). show ();

}

})

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.