安卓2.2:重新启动设备编程 [英] Android 2.2: Reboot device programmatically
本文介绍了安卓2.2:重新启动设备编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否有一种方法来重新启动设备通过code。香港专业教育学院的尝试:
I would like to know if there is a way to reboot the device through code. Ive tried:
Intent i = new Intent(Intent.ACTION_REBOOT);
i.putExtra("nowait", 1);
i.putExtra("interval", 1);
i.putExtra("window", 0);
sendBroadcast(i);
和添加权限重启
,但它仍然不工作。
And added permissions for REBOOT
but it still doesnt work.
感谢
推荐答案
这似乎为我工作:
try {
Process proc = Runtime.getRuntime().exec(new String[] { "su", "-c", "reboot" });
proc.waitFor();
} catch (Exception ex) {
Log.i(TAG, "Could not reboot", ex);
}
这篇关于安卓2.2:重新启动设备编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文