1.注册一个广播,在广播的onReceive()方法中启动主Activity
Intent intent = new Intent(context, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
2.在Activity的onCreat()方法中添加两句话
// 锁屏也要显示
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
// 隐藏掉键盘
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);