重启://发送广播
Intent reboot = new Intent(Intent.ACTION_REBOOT);
reboot.putExtra("nowait",1);
reboot.putExtra("interval",1);
reboot.putExtra("window",0);
sendBroadcast(reboot);
关机://启动 Activity
Intent shutdown = new Intent(Intent.ACTION_REQUEST_SHUTDOWN);
shutdown.putExtra(Intent.EXTRA_KEY_CONFIRM,showShutdownDialog);
shotdown.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(shutdown);
本文介绍了在Android平台上通过发送广播实现设备重启的方法及通过启动特定Activity来请求系统关机的功能。这两种方法为开发者提供了在应用层面控制设备开关的能力。
2937

被折叠的 条评论
为什么被折叠?



