重新启动运行4.0的Android设备

重新启动运行4.0的Android设备,android,exception,reboot,Android,Exception,Reboot,我已在清单中设置权限: <uses-permission android:name="android.permission.REBOOT" /> 由于我在emulator中拥有root权限,我很好奇为什么会遇到以下错误: Permission Denial: not allowed to send broadcast android.intent.action.REBOOT from pid=963, uid=10046 重新启动权限仅授予具有平台签名或作为系统应用程序的应用程

我已在清单中设置权限:

<uses-permission android:name="android.permission.REBOOT" />
由于我在emulator中拥有root权限,我很好奇为什么会遇到以下错误:

 Permission Denial: not allowed to send broadcast android.intent.action.REBOOT from pid=963, uid=10046

重新启动权限仅授予具有平台签名或作为系统应用程序的应用程序


成为root用户可能允许您以root用户身份运行命令,但您的应用程序仍然不是。(不过,您可以调用shutdown命令)

如果有人仍在查看,并且我们确实在讨论根设备,请阅读

应使用以下代码示例(根据请求添加):


你有什么建议可以在模拟器上安装一个自定义的mod,这样我的应用程序就可以拥有与操作系统相同的签名证书吗?
 Permission Denial: not allowed to send broadcast android.intent.action.REBOOT from pid=963, uid=10046
Process rebootProcess = null;
try
{
    rebootProcess = Runtime.getRuntime().exec("su -c reboot now");
}
catch (IOException e)
{
    // Handle I/O exception.
}

// We waitFor only if we've got the process.
if (rebootProcess != null)
{
    try
    {
        rebootProcess.waitFor();
    }
    catch (InterruptedException e)
    {
        // Now handle this exception.
    }
}