Android代码实现关机重启
16lz
2021-12-20
关机:
重启:
加上
Intent shutdown = new Intent(Intent.ACTION_REQUEST_SHUTDOWN); shutdown.putExtra(Intent.EXTRA_KEY_CONFIRM, false); shutdown.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mContext.startActivity(shutdown);
重启:
Intent reboot = new Intent(Intent.ACTION_REBOOT);reboot.putExtra("nowait", 1);reboot.putExtra("interval", 1);reboot.putExtra("window", 0);sendBroadcast(reboot);
加上
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" [color=red]android:sharedUserId="android.uid.system"[/color] android:versionName="1.0">
更多相关文章
- Android为Notification加上一个进度条
- Android(安卓)面试之横竖屏切换的Activity生命周期
- Android判断网络状态
- Android关机流程解析
- Android(安卓)SDK无法更新怎么办
- 为TextView添加上下边框
- Android(安卓)tabhost让选中项加上背景图
- Android关机界面代码
- 【Android】adb 查看所有程序包名