IT资讯
联系方式
IT资讯您当前的位置:主页 > IT资讯 >

Android锁屏状态下弹出activity

发布于:2019-02-01 作者:918Õ

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中加入该权限:


http://www.bkjia.com/Androidjc/869622.htmlwww.bkjia.comtruehttp://www.bkjia.com/Androidjc/869622.htmlTechArticleAndroid锁屏状态下弹出activity 在接收消息广播的onReceive里,跳转到你要显示的界面。如: Intent intent = new Intent(arg0,MainActivity.class);intent.addFl...

本文源自: 凯发国际