You do almost everything right. Keep doing what you do with BroadcastReceiver. This is the way. For Window, these are the flags you should use:
- WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
- WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
Use not FLAG_DISMISS_KEYGAURD
What these flags do: SHOW_WHEN_LOCKED allows your activity to appear on top of the lock screen. FLAG_NOT_TOUCH_MODAL allows touch events that are not part of your activity to go to other actions, i.e. Allows the user to unlock the screen. FLAG_DISMISS_KEYGUARD gets rid of the lock screen, so we do not use it.
Define this style in res / values /styles.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <style name="Theme.FloatingTranslucent" parent="android:Theme.Translucent.NoTitleBar"> <item name="android:windowIsFloating">true</item> </style> </resources>
In the manifest, define the style of your activity
<activity android:name=".SampleActivity" android:theme="@style/Theme.FloatingTranslucent"> ... </activity>
This means that your activity is fully viewing and transferring content.
Now your activity should be on top of the lock screen, allowing touch input on the lock screen and in your application, while your activity will not be complete.
Greetings.
Zaid Daghestani Jun 05 2018-12-12T00: 00Z
source share