Android锁屏状态下弹出activity

在接收消息广播的onReceive里,跳转到你要显示的界面。如:

Intent intent = new Intent(arg0,MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);        
arg0.startActivity(intent);

在该activity的onCreate()方法里:

super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED|WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
setContentView(R.layout.activity_main);

设置activity的theme属性:

android:theme="@android:style/Theme.Wallpaper.NoTitleBar"

添加点击事件,进入app,突破锁屏:

KeyguardManager keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("");
keyguardLock.disableKeyguard();

在menifest中加入该权限:

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


Android锁屏状态下弹出activity

上一篇:WEB APP 开发标签


下一篇:开发者必须mark的一款2D移动游戏开发工具