先试一下用Application的上下文来创建Dialog,在调用它的show方法时程序会Crash,LogCat的异常信息如下: Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application at android.view.ViewRootImpl.setView(ViewRootImpl.java:685) at android.view.Windo...
在自定义Diaglog进行展示时,提示:Unable to add window -- token null is not for an application 这是由于Context的定义不一样造成的,这里不能使用Application的Context,而要使用Activity,因为只有Activity才能展示对话框。 修改自定义对话框的大小 TextView view = new TextView(this); view.setBackgroundColor(Co...
Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application 解决方法:可能是context的错误,进行排查。
Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application 这个错误意思就是 token为空,所以添加不上view,我在网上查相关信息,他们说传入的context对象有问题,但是我反复测试在activity中启动widnow并且添加view是正常的,难道就不能在发起一个广播启动...
代码中出现如下错误: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application 分析: 问题在于new AlertDialog.Builder(Context),虽然这里的参数是AlertDialog.Builder(Context context) 但我们不能使用getApplicationContext()获得的Context,而必须使用Activity的Context...
Unable to add window -- token null is not for an application错误的解决方法 android开发 Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application 解决方法:可能是context的错误,进行排查。
您必须在您的身份验证器类中创建构造函数,它将为class.And提供上下文,通过调用此构造函数将上下文传递给...
Your Android.App.Application.Context is Application Context, not Activity Context. Or you need get your MainActivity's Context and the pass it into your Builder() method. And one more question, are you using DependencyService?when I am adding this to my code-->複製...
原因是因为Dialog 不能用getApplicationContext(),原因是因为Token必须是Activity的Token,不然的话会抛出异常 btn.setOnClickListener(newView.OnClickListener(){@OverridepublicvoidonClick(Viewview){CommomDialogcommomDialog=newCommomDialog(Test2Activity.this,R.style.dialog,"是否要删除门店",newCommomDialog.On...
08-07 21:26:43.506: ERROR/AndroidRuntime(9390): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application LoadingDialog dialog=newLoadingDialog(context); 其中context为Fragment中 context = getApplicationContext(); ...