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 ();
}
})