简体   繁体   English

在锁定屏幕上显示弹出窗口

[英]show popup window on lock screen

I have implemented a caller ID feature where when the screen is locked it should open the lock and show the popup with the name of the person calling. 我已经实现了呼叫者ID功能,该功能可以在锁定屏幕时打开锁定并显示带有呼叫者姓名的弹出窗口。

this is the code i've added in the onCreate() of the PopupActivity. 这是我添加到PopupActivity的onCreate()中的代码。

 getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
            WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
            WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
            WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

I've also added the permissions 我还添加了权限

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

This works fine when the phone is not password/pattern protected.However it shows a black background to the popup window when the device is password/pattern protected disabling the user from attending/rejecting the call. 当电话没有密码/图案保护时,此方法效果很好。但是,如果设备受到密码/图案保护,则在弹出窗口中显示黑色背景,使用户无法接听/拒绝电话。

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON |PixelFormat.TRANSLUCENT);

这似乎对我有用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM