public boolean goToSleep() {
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
try {
Method method = pm.getClass().getMethod("goToSleep", Long.TYPE);
method.invoke(pm, SystemClock.uptimeMillis());
return true;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
<uses-permission android:name="android.permission.DEVICE_POWER" />
android:sharedUserId="android.uid.system"//并使用系统签名
















