ritesh07/30/2020, 8:12 AM
to display an overlay across all activities. Why not use
and Services like every other stackoverflow solution tells me to do that. Requirement is to add a chat feature in the app, that would be available across all activities in minimized view once initiated - you can start a chat within one activity and keep it live when changing activities. Solution -> Use this permission, and create a service, to overlay across all screens.
Problem with the requirement we have -> 1. I don't need a view visible over all applications - a view visible only to our app. 2. Using the above solution requires run time permission from users for api level above >=M. 3. User can disable this permission from settings, and overlay won’t work. 4. this permission is not available on all devices, and I suspect that it will be retired in a year or two.
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
KamilH07/30/2020, 8:29 AM
. I’m adding custom view to the Resumed Activity Window via
and I’m removing it from Stopped Activity via
Every time user drags the view I’m updating it with
. It works pretty well There are few problems to solve: I’m using
on the draggable view to move it around so click events needs to be handled differently. My biggest issue is that there is a default Window animation that is trying to animate window size changes and it doesn’t look good in my case (I have an expand/collapse feature of the draggable view). The animation is possible to disable only via reflection: https://stackoverflow.com/a/33171254/3448282 or add custom container (FrameLayout for example) to the WindowManager instead of adding draggable view itself and handle everything manually
ritesh07/30/2020, 8:48 AM
KamilH07/30/2020, 8:52 AM
ritesh07/30/2020, 8:54 AM