show popup window on lock screen
Asked Answered
E

1

0

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.

this is the code i've added in the onCreate() of the PopupActivity.

 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.

Ezarra answered 28/8, 2017 at 5:10 Comment(0)
E
1

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);

This seems to be working for me

Ezarra answered 30/8, 2017 at 4:29 Comment(1)
Can you please share the full process?Ymir

© 2022 - 2024 — McMap. All rights reserved.