灯火互联
管理员
管理员
  • 注册日期2011-07-27
  • 发帖数41778
  • QQ
  • 火币41290枚
  • 粉丝1086
  • 关注100
  • 终身成就奖
  • 最爱沙发
  • 忠实会员
  • 灌水天才奖
  • 贴图大师奖
  • 原创先锋奖
  • 特殊贡献奖
  • 宣传大使奖
  • 优秀斑竹奖
  • 社区明星
阅读:3815回复:1

android 中 FLAG_SHOW_WHEN_LOCKED 的用法及解释

楼主#
更多 发布于:2012-10-22 13:52

如何让一个activity 浮在锁屏界面的上方,返回即进入解锁界面。
譬如在锁屏界面,来电时是不需要先解锁才能接听电话的。这样能带来快捷。
如果你想在android 上实现 iphone 4s 上面在锁屏界面就能进照相机的话也可以按此方式来进行。
只需要在 Camera 的 activity 的 onResume 函数中添加如下 flag 即可实现。


import android.view.Window;
import android.view.WindowManager;


final Window win = activity.getWindow();
final WindowManager.LayoutParams params = win.getAttributes();
params.flags |= WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;


       /** Window flag: special flag to let windows be shown when the screen
         * is locked. This will let application windows take precedence over
         * key guard or any other lock screens. Can be used with
         * {@link #FLAG_KEEP_SCREEN_ON} to turn screen on and display windows
         * directly before showing the key guard window.  Can be used with
         * {@link #FLAG_DISMISS_KEYGUARD} to automatically fully dismisss
         * non-secure keyguards.  This flag only applies to the top-most
         * full-screen window.
         */
        public static final int FLAG_SHOW_WHEN_LOCKED = 0x00080000

喜欢0 评分0
wldtk
新手上路
新手上路
  • 注册日期2012-10-11
  • 发帖数38
  • QQ
  • 火币41枚
  • 粉丝1
  • 关注0
沙发#
发布于:2012-11-26 15:13
选择千锋 选择卓越  千锋3G 手机软件开发培训第一品牌

iphone培训
千锋iphone培训

回复(0) 喜欢(0)     评分
游客

返回顶部