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

时间:2011-05-23 21:42:09

标签: android reboot

这是一个很长的故事,但我试图调用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);
}

2 个答案:

答案 0 :(得分:0)

在调用reboot()尝试给getParent()上下文参数时,请参阅。

答案 1 :(得分:0)

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

  

android.permission.SYSTEM_ALERT_WINDOW