`

Android代码实现关机重启

阅读更多
关机:
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">
分享到:
评论
2 楼 kallyena 2011-11-05  
没找到Intent.EXTRA_KEY_CONFIRM这个常量
1 楼 pop1030123 2011-09-18  
LZ,有没有发现Intent.EXTRA_KEY_CONFIRM这个常量根本没有。

相关推荐

Global site tag (gtag.js) - Google Analytics