android 5.1重启android设备



如何以编程方式重启android设备,我使用下面的代码来重启我的设备

Process proc = null;
try {
//proc = Runtime.getRuntime().exec(new String[] { "su", "-c", "reboot" });
proc = Runtime.getRuntime().exec(new String[]{"/system/bin/su","-c","reboot now"});
proc.waitFor();
} catch (Exception ex) {
Log.i(TAG, "Could not reboot", ex);
}

和许可,我使用这个

PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
pm.reboot(null);

请帮助我,让我知道是否可能?我需要这个在android 5.1

你可以使用PowerManager让它重新启动。

http://developer.android.com/reference/android/os/PowerManager.html重启(以)

有一个库来重新启动设备。您可以使用以下命令

重新启动
code: Shell.SU.run("reboot");

Library: https://github.com/Chainfire/libsuperuser

最新更新