如何以编程方式关机一个根深蒂固的手机? [英] How to power off programmatically a rooted phone ?
本文介绍了如何以编程方式关机一个根深蒂固的手机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想我的设备的电源programically我的手机是植根但该命令没有我的设备的电源有什么不好?
I want to power of my device programically my phone is rooted but this command not power of my device what is wrong ?
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Process chperm;
try {
chperm=Runtime.getRuntime().exec("su");
DataOutputStream os =
new DataOutputStream(chperm.getOutputStream());
os.writeBytes("reboot -p\n");
os.flush();
chperm.waitFor();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
我如何透过程式设计断电装置?
How do I power off device programtically ?
推荐答案
希望这会为你工作。
Intent shutdown = new Intent("android.intent.action.ACTION_REQUEST_SHUTDOWN");
shutdown.putExtra("android.intent.extra.KEY_CONFIRM", false);
shutdown.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
thisActivity.startActivity(shutdown);
这篇关于如何以编程方式关机一个根深蒂固的手机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文