gpt4 book ai didi

android - 重启android设备的Button的onClick事件

转载 作者:太空宇宙 更新时间:2023-11-03 12:23:17 26 4
gpt4 key购买 nike

我想重启我的手机我试过了

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

而且 PowerManager 也看到了我的编码,但设备在这两种编码中都没有重启,请提供工作代码

          ok = (Button)findViewById(R.id.button1);
final PowerManager power = (PowerManager)getSystemService(Context.POWER_SERVICE);

ok.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
power.reboot("fav");
}
});

最佳答案

You cannot do a reboot from an ordinary SDK application. Only applications signed with the system firmware signing key can do this.

从这个答案复制,Programmatically switching off Android phone

关于android - 重启android设备的Button的onClick事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9257980/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com