清单文件申请权限
<!-- 保持屏幕亮起权限 -->
<uses-permission android:name="android.permission.WAKE_LOCK" >
</uses-permission>
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" >
</uses-permission>
添加到activity onCreate的setContentView(); 前
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED//锁屏状态下显示
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD//解锁
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON//保持屏幕长亮
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON//打开屏幕
);
setContentView(R.layout.activity_close);
initView();
}