WindowManager$BadTokenException: Unable to add window permission denied for this window type

10-11 11:47:27.472: E/AndroidRuntime(12804): java.lang.RuntimeException: Unable to start activity ComponentInfo{cn.zhl.classguiding/cn.zhl.classguiding.XueanPdfActivity}: android.view.WindowManager$BadTokenException: Unable to add window [email protected] -- permission denied for this window type
10-11 11:47:27.472: E/AndroidRuntime(12804): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
10-11 11:47:27.472: E/AndroidRuntime(12804): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
10-11 11:47:27.472: E/AndroidRuntime(12804): at android.app.ActivityThread.access$600(ActivityThread.java:123)
10-11 11:47:27.472: E/AndroidRuntime(12804): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
10-11 11:47:27.472: E/AndroidRuntime(12804): at android.os.Handler.dispatchMessage(Handler.java:99)
10-11 11:47:27.472: E/AndroidRuntime(12804): at android.os.Looper.loop(Looper.java:137)
10-11 11:47:27.472: E/AndroidRuntime(12804): at android.app.ActivityThread.main(ActivityThread.java:4424)
10-11 11:47:27.472: E/AndroidRuntime(12804): at java.lang.reflect.Method.invokeNative(Native Method)
10-11 11:47:27.472: E/AndroidRuntime(12804): at java.lang.reflect.Method.invoke(Method.java:511)
10-11 11:47:27.472: E/AndroidRuntime(12804): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
10-11 11:47:27.472: E/AndroidRuntime(12804): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
10-11 11:47:27.472: E/AndroidRuntime(12804): at dalvik.system.NativeStart.main(Native Method)
10-11 11:47:27.472: E/AndroidRuntime(12804): Caused by: android.view.WindowManager$BadTokenException: Unable to add window [email protected] -- permission denied for this window type
10-11 11:47:27.472: E/AndroidRuntime(12804): at android.view.ViewRootImpl.setView(ViewRootImpl.java:537)
10-11 11:47:27.472: E/AndroidRuntime(12804): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:301)
10-11 11:47:27.472: E/AndroidRuntime(12804): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:215)
10-11 11:47:27.472: E/AndroidRuntime(12804): at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:140)
10-11 11:47:27.472: E/AndroidRuntime(12804): at android.view.Window$LocalWindowManager.addView(Window.java:537)
10-11 11:47:27.472: E/AndroidRuntime(12804): at cn.zhl.classguiding.XueanPdfActivity.createFloatView(XueanPdfActivity.java:1854)
10-11 11:47:27.472: E/AndroidRuntime(12804): at cn.zhl.classguiding.XueanPdfActivity.onCreate(XueanPdfActivity.java:415)
10-11 11:47:27.472: E/AndroidRuntime(12804): at android.app.Activity.performCreate(Activity.java:4465)
10-11 11:47:27.472: E/AndroidRuntime(12804): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
10-11 11:47:27.472: E/AndroidRuntime(12804): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
10-11 11:47:27.472: E/AndroidRuntime(12804): ... 11 more

修改方法:manifest.xml 添加权限

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.SYSTEM_OVERLAY_WINDOW" />

时间: 2024-11-05 12:33:29

WindowManager$BadTokenException: Unable to add window permission denied for this window type的相关文章

Android Studio:Unable to add window [email&#160;protected] -- permission denied for this window 第一行代码

学习<第一行代码>的时候,出现的错误. java.lang.RuntimeException: Unable to start receiver com.example.sevenun.littledemo.receiver.ForceOfflineReceiver: android.view.WindowManager$BadTokenException: Unable to add window [email protected] -- permission denied for this

Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

在广播中启动一个Dialog时出现如下错误信息:Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application 在代码中添加了dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);错误信息没有消除, 此时在Manifest.xml文件中

bug_android.view.WindowManager$BadTokenException: Unable to add window -- token

========5 java.lang.IllegalArgumentException: View not attached to window manager at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:653) at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:349) at android.view.Wi

Android报错:WindowManager$BadTokenException: Unable to add window -- window has already been added

很久之前测试通过的代码,现在手机升级了Android7.0后一运行就崩溃,报出这样的错误,具体错误如下: Process: com.example.sho.android_anti_theft, PID: 26807 android.view.WindowManager$BadTokenException: Unable to add window -- window [email protected] has already been added at android.view.ViewRoo

关于ProgressDialog.show抛出android.view.WindowManager$BadTokenException: Unable to add window

下午摆弄ProgressDialog,进入就抛错:android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application,让我百思不得其解.我这使用这种方法实现的进度对话框:proDialog = ProgressDialog.show(getApplicationContext(), "sadfs", "dddddd",tr

android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

原博客地址:http://aijiawang-126-com.javaeye.com/blog/662336 在Activity中newSpinner是我把mContext传入,但是出了 android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application这个错误,参考了达人的文章终于搞定. [java] view plaincopy private C

bug_ _ android.view.WindowManager$BadTokenException: Unable to add window -- token

android.view.WindowManager$BadTokenException: Unable to add window -- token [email protected] is not valid; is your activity running?at android.view.ViewRootImpl.setView(ViewRootImpl.java:546)at android.view.WindowManagerImpl.addView(WindowManagerImp

Android自用-----WindowManager$BadTokenException: Unable to add window -- token null is not for an application

转自http://www.cnblogs.com/oakpip/archive/2011/04/06/2007310.html 错误产生: private Context mcontext; @Override protected void onCreate(Bundle savedInstanceState) {mcontext = getApplicationContext(); System.out.println("mcontext=" + mcontext); } new A

android.view.WindowManager$BadTokenException: Unable to add window

解决方法:AlertDialog.Builder(xxx.this) => AlertDialog.Builder(this.getParent()) 或(this)改为(xxx.this)