androidservicewindow-managerssystem-alert-window

Android: is it a good idea to display views with a windowmanager in a service?


I'm making a kind of minigame thats played in an android service, so the background is whatever you were doing on your phone at the time, the game starts when you click on the foreground notification. Everything is displayed with a windowmanager with the system_alert_window permission. Im wondering if this is something thats a good thing to do or should this be only used for important things. Would it be a better idea to start a transparent activity and display everything in there?


Solution

  • This is actually how Facebook Messenger Chat Heads are implemented.

    Functionally, there's nothing "wrong" with it as long as the user is expecting it. It could be rather jarring to have something interrupt them in the middle of a session with another app.

    The downside to implementing this is the Service (and corresponding alert) can be killed at any time. This in fact happens quite often with even Messenger. Another app is in the foreground so it takes precedence over your game. Implementing it in a transparent activity would not be a way to overcome this.