提示的错误是权限问题,但是代码是一样的,manifest里面也给了REBOOT权限,在网上找了一下解释还是没有什么好的解决方案,错误信息如下:

  [plain] view plaincopyprint?

  01-01 08:05:26.319 W/System.err( 776): java.io.IOException: Error running exec(). Command: [su, -c, reboot] Working Directory: null Environment: null

  01-01 08:05:26.319 W/System.err( 776): at java.lang.ProcessManager.exec(ProcessManager.java:211)

  01-01 08:05:26.319 W/System.err( 776): at java.lang.Runtime.exec(Runtime.java:168)

  01-01 08:05:26.319 W/System.err( 776): at java.lang.Runtime.exec(Runtime.java:241)

  01-01 08:05:26.319 W/System.err( 776): at java.lang.Runtime.exec(Runtime.java:184)

  01-01 08:05:26.319 W/System.err( 776): at com.android.settings.DevelopmentSettings.exeShell(DevelopmentSettings.java:591)

  01-01 08:05:26.319 W/System.err( 776): at com.android.settings.DevelopmentSettings.onPreferenceChange(DevelopmentSettings.java:580)

  01-01 08:05:26.319 W/System.err( 776): at android.preference.Preference.callChangeListener(Preference.java:885)

  01-01 08:05:26.319 W/System.err( 776): at android.preference.ListPreference.onDialogClosed(ListPreference.java:265)

  01-01 08:05:26.329 W/System.err( 776): at android.preference.DialogPreference.onDismiss(DialogPreference.java:381)

  01-01 08:05:26.329 W/System.err( 776): at android.app.Dialog$ListenersHandler.handleMessage(Dialog.java:1235)

  01-01 08:05:26.329 W/System.err( 776): at android.os.Handler.dispatchMessage(Handler.java:99)

  01-01 08:05:26.329 W/System.err( 776): at android.os.Looper.loop(Looper.java:137)

  01-01 08:05:26.329 W/System.err( 776): at android.app.ActivityThread.main(ActivityThread.java:4424)

  01-01 08:05:26.329 W/System.err( 776): at java.lang.reflect.Method.invokeNative(Native Method)

  01-01 08:05:26.329 W/System.err( 776): at java.lang.reflect.Method.invoke(Method.java:511)

  01-01 08:05:26.329 W/System.err( 776): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)

  01-01 08:05:26.329 W/System.err( 776): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)

  01-01 08:05:26.329 W/System.err( 776): at dalvik.system.NativeStart.main(Native Method)

  01-01 08:05:26.329 W/System.err( 776): Caused by: java.io.IOException: Permission denied

  01-01 08:05:26.329 W/System.err( 776): at java.lang.ProcessManager.exec(Native Method)

  01-01 08:05:26.339 W/System.err( 776): at java.lang.ProcessManager.exec(ProcessManager.java:209)

  01-01 08:05:26.339 W/System.err( 776): ... 17 more

  01-01 08:05:26.369 W/InputManagerService( 174): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@4138ecb8

  01-01 08:05:26.319 W/System.err( 776): java.io.IOException: Error running exec(). Command: [su, -c, reboot] Working Directory: null Environment: null

   01-01 08:05:26.319 W/System.err( 776): at java.lang.ProcessManager.exec(ProcessManager.java:211)

  01-01 08:05:26.319 W/System.err( 776): at java.lang.Runtime.exec(Runtime.java:168)

  01-01 08:05:26.319 W/System.err( 776): at java.lang.Runtime.exec(Runtime.java:241)

  01-01 08:05:26.319 W/System.err( 776): at java.lang.Runtime.exec(Runtime.java:184)

  01-01 08:05:26.319 W/System.err( 776): at com.android.settings.DevelopmentSettings.exeShell(DevelopmentSettings.java:591)

  01-01 08:05:26.319 W/System.err( 776): at com.android.settings.DevelopmentSettings.onPreferenceChange(DevelopmentSettings.java:580)

  01-01 08:05:26.319 W/System.err( 776): at android.preference.Preference.callChangeListener(Preference.java:885)

  01-01 08:05:26.319 W/System.err( 776): at android.preference.ListPreference.onDialogClosed(ListPreference.java:265)

  01-01 08:05:26.329 W/System.err( 776): at android.preference.DialogPreference.onDismiss(DialogPreference.java:381)

  01-01 08:05:26.329 W/System.err( 776): at android.app.Dialog$ListenersHandler.handleMessage(Dialog.java:1235)

  01-01 08:05:26.329 W/System.err( 776): at android.os.Handler.dispatchMessage(Handler.java:99)

  01-01 08:05:26.329 W/System.err( 776): at android.os.Looper.loop(Looper.java:137)

  01-01 08:05:26.329 W/System.err( 776): at android.app.ActivityThread.main(ActivityThread.java:4424)

  01-01 08:05:26.329 W/System.err( 776): at java.lang.reflect.Method.invokeNative(Native Method)

  01-01 08:05:26.329 W/System.err( 776): at java.lang.reflect.Method.invoke(Method.java:511)

  01-01 08:05:26.329 W/System.err( 776): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)

  01-01 08:05:26.329 W/System.err( 776): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)

  01-01 08:05:26.329 W/System.err( 776): at dalvik.system.NativeStart.main(Native Method)

  01-01 08:05:26.329 W/System.err( 776): Caused by: java.io.IOException: Permission denied

  01-01 08:05:26.329 W/System.err( 776): at java.lang.ProcessManager.exec(Native Method)

  01-01 08:05:26.339 W/System.err( 776): at java.lang.ProcessManager.exec(ProcessManager.java:209)

  01-01 08:05:26.339 W/System.err( 776): ... 17 more

  01-01 08:05:26.369 W/InputManagerService( 174): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@4138ecb8