窗口管理$ BadTokenException:无法添加窗口android.view.ViewRoot$W@4 5985ae0 - 拒绝使用此窗口类型权限 [英] WindowManager$BadTokenException: Unable to add window android.view.ViewRoot$W@4 5985ae0 -- permission denied for this window type

查看:203
本文介绍了窗口管理$ BadTokenException:无法添加窗口android.view.ViewRoot$W@4 5985ae0 - 拒绝使用此窗口类型权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个很长的故事,但我试图调用ShutdownThread目录重启手机,由于某种原因,因为它给了我这个错误...任何帮助将是AP $它不喜欢我的情况下,等p $ pciated ....

  .NativeStart.main(本机方法)
     [执行] 05-23 16:32:36.354 5573 5573W¯¯System.err的:android.view:产生的原因
.WindowManager $ BadTokenException:无法添加窗口android.view.ViewRoot$W@4
5985ae0 - 权限被拒绝这种​​窗型
     [执行] 05-23 16:32:36.362 5573 5573W¯¯System.err的:在android.view。
/ **
 *申请一个干净的关闭,等待子系统清理自己
 *状态等必须从弯针线被称为在其UI
 *所示。
 *
 * @参数上下文语境用于显示关闭进度对话框。
 * @参数原因code传递给内核(如复苏),或者为null。
 * @参数确认true,如果用户确认关闭之前需要。
 * /
公共静态无效重启(最终上下文的背景下,字符串原因,布尔确认){
    mReboot = TRUE;
    mRebootReason =原因;
    关机(背景下,确认);
}


解决方案

尝试添加以下权限的 AndroidManifest 。如果你不用它。


  

android.permission.SYSTEM_ALERT_WINDOW


It's a long story, but I'm trying to call the ShutdownThread directory to restart the phone and for some reason it does not like my context, etc. as it gives me this error...any help would be appreciated....

.NativeStart.main(Native Method)
     [exec] 05-23 16:32:36.354  5573  5573 W System.err: Caused by: android.view
.WindowManager$BadTokenException: Unable to add window android.view.ViewRoot$W@4
5985ae0 -- permission denied for this window type
     [exec] 05-23 16:32:36.362  5573  5573 W System.err:        at android.view.


/**
 * Request a clean shutdown, waiting for subsystems to clean up their
 * state etc.  Must be called from a Looper thread in which its UI
 * is shown.
 *
 * @param context Context used to display the shutdown progress dialog.
 * @param reason code to pass to the kernel (e.g. "recovery"), or null.
 * @param confirm true if user confirmation is needed before shutting down.
 */
public static void reboot(final Context context, String reason, boolean confirm) {
    mReboot = true;
    mRebootReason = reason;
    shutdown(context, confirm);
}

解决方案

Try adding following permission in AndroidManifest. In case you don't have it.

android.permission.SYSTEM_ALERT_WINDOW

这篇关于窗口管理$ BadTokenException:无法添加窗口android.view.ViewRoot$W@4 5985ae0 - 拒绝使用此窗口类型权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆