Android关机重启

AndroidManifest.xml 加上权限

<manifest ...... android:sharedUserId="android.uid.system"/>

<uses-permission android:name="android.permission.SHUTDOWN" />

代码

关机:

Intent intent = new Intent(Intent.ACTION_REQUEST_SHUTDOWN);

intent.putExtra(Intent.EXTRA_KEY_CONFIRM, false);

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

startActivity(intent);

重启:

Intent i = new Intent(Intent.ACTION_REBOOT);
i.putExtra("nowait", 1);
i.putExtra("interval", 1);
i.putExtra("window", 0);
sendBroadcast(i); 

Android.mk 加一行

LOCAL_CERTIFICATE := platform

须使用Linux mm命令来编译apk

关机的相关并没有开放 所以直接在eclipse里面是会报错的

原文地址:https://www.cnblogs.com/jayceli/p/2428626.html