问题
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);
}
回答1:
While calling your reboot()
try giving getParent()
for the context parameter and see.
回答2:
Try adding following permission in AndroidManifest. In case you don't have it.
android.permission.SYSTEM_ALERT_WINDOW
来源:https://stackoverflow.com/questions/6103401/windowmanagerbadtokenexception-unable-to-add-window-android-view-viewrootw4