Android(安卓)代码实现关机重启
16lz
2021-12-04
关机:
In frameworks/base/services/java/com/android/server/BatteryService.java
Intent intent = new Intent(Intent.ACTION_REQUEST_SHUTDOWN);
intent.putExtra(Intent.EXTRA_KEY_CONFIRM, false);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intent);
重启:
Intent i = new Intent(Intent.ACTION_REBOOT);
i.putExtra("nowait", 1);
i.putExtra("interval", 1);
i.putExtra("window", 0);
sendBroadcast(i);
注意添加权限。
来自: http://topic.csdn.net/u/20100423 ... 2-55f6c4c5e412.html
In frameworks/base/services/java/com/android/server/BatteryService.java
Intent intent = new Intent(Intent.ACTION_REQUEST_SHUTDOWN);
intent.putExtra(Intent.EXTRA_KEY_CONFIRM, false);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intent);
重启:
Intent i = new Intent(Intent.ACTION_REBOOT);
i.putExtra("nowait", 1);
i.putExtra("interval", 1);
i.putExtra("window", 0);
sendBroadcast(i);
注意添加权限。
来自: http://topic.csdn.net/u/20100423 ... 2-55f6c4c5e412.html
更多相关文章
- 【Android】hwbinder的selinux配置
- Android(安卓)在指定 LinearLayout 中动态添加BUTTON,并设置样式
- android应用去掉title bar 及全屏处理方法
- Android(安卓)实现全屏和无标题栏的显示
- android关机充电流程、充电画面显示
- 改变android程序head样式
- android中广播接收者BroadcastReceiver
- Android(安卓)Dialog的使用
- Android在设置里面添加新功能的方法