WindowManager$BadTokenException:无法添加窗口 android.view.ViewRoot$W@4 5985ae0 -- 此窗口类型的权限被拒绝

发布于 2024-11-09 02:54:03 字数 999 浏览 1 评论 0原文

这是一个很长的故事,但我试图调用 ShutdownThread 目录来重新启动手机,并且由于某种原因它不喜欢我的上下文等,因为它给了我这个错误......任何帮助将不胜感激......

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

太傻旳人生 2024-11-16 02:54:03

在调用 reboot() 时,尝试为上下文参数提供 getParent() 并查看。

While calling your reboot() try giving getParent() for the context parameter and see.

画骨成沙 2024-11-16 02:54:03

尝试在 AndroidManifest 中添加以下权限。万一你没有它。

android.permission.SYSTEM_ALERT_WINDOW

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

android.permission.SYSTEM_ALERT_WINDOW

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文