OnCreate of your Service: I have used _WATCH_OUTSIDE_TOUCH flag. Therefore, it is better to create the view and assign it to the window manager by a foreground service. If you can improve it, please let me know. Note: If your application gets destroyed, your view will be removed from the window manager.Any pointers on how to do this would be helpful.Īttaching a screenshot of the floating view for better understanding: Secondly, I would also like to dismiss this floating view when there is SYSTEM BACK/HARDWARE BACK button press event. The initial release targets foldable devices, but future versions will extend to more display types and window features. The library provides a common API surface for API versions 14 and later. This will let application windows take precedence over key guard or any other lock. What I would like to know is â if this is the right way to approach the problem or are there any better ways to do it? And, should I make changes to the LayoutParams or keep them as is? The Jetpack WindowManager library enables application developers to support new device form factors and multi-window environments. view.WindowManagerBadTokenException: Unable to add window - token null is not valid is your activity running params.type WindowManager.LayoutParams. Window flag: special flag to let windows be shown when the screen is locked. Whenever a user performs any action on the view, I'm removing the view from window manager and killing the service. LayoutParams layOutParams = new WindowManager.LayoutParams( The following is the code I'm using to create the view. Upon receiving the event, I'm starting a service to display the floating view. I have a broadcast receiver which will listen for Alarm events. In the manifest I added permissions for:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |