WindowManager$BadTokenException:无法添加窗口 android.view.ViewRoot$W@4 5985ae0 -- 此窗口类型的权限被拒绝
这是一个很长的故事,但我试图调用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在调用
reboot()
时,尝试为上下文参数提供getParent()
并查看。While calling your
reboot()
try givinggetParent()
for the context parameter and see.尝试在 AndroidManifest 中添加以下权限。万一你没有它。
Try adding following permission in AndroidManifest. In case you don't have it.