一叶梧桐

实现:编辑短信,按power键锁屏后,再点亮屏幕,进入的还是编辑短信界面,按返回键才会进入解锁界面。

描述:在编辑短信界面按电源键锁屏后,重新按电源键点亮屏幕,并没有进入到锁屏界面而是在编辑短信界面,此时短信界面悬浮与锁屏界面之上,这时按返回键关闭编辑短信界面,回到锁屏界面,是如何实现的呢,只需要在需要实现该功能的界面(Activity)中的onCreate()方法中setContentView()方法之前添加以下代码:

     // set this flag so this activity will stay in front of the keyguard
        int flags = WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
        WindowManager.LayoutParams lp = getWindow().getAttributes();
        lp.flags |= flags;


posted on 2014-06-13 11:18  一叶梧桐  阅读(152)  评论(0编辑  收藏  举报