WindowManager$BadTokenException: Unable to add window android.view.ViewRoot$W@4 5985ae0 -- permission denied for this window type
Asked Answered
S

2

0

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);
}
Sabir answered 23/5, 2011 at 21:42 Comment(1)
If you find this answer is right, accept it by putting the tick mark. Otherwise describe the issue. If you got another solution, post that..Lifer
L
0

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

Lifer answered 24/5, 2011 at 5:41 Comment(0)
I
0

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

android.permission.SYSTEM_ALERT_WINDOW

Irreplaceable answered 8/7, 2013 at 8:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.