Search code examples
androidstatusbar

Service and Status Bar


I want to hide Status Bar using service. I can't getWindow() in service from obvious resons.

I am using this code in normal activity:

                    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                                WindowManager.LayoutParams.FLAG_FULLSCREEN);

But when i clickback button status bar appearing again. I want to have status bar hidden even after closing application. Is this possible?


Solution

  • With the posted code you can hide the status bar when your application is running in foreground ("in front of the user"). But once you close the application (e.g. using the back button), or when it goes in the background, Android re-enables the status automatically, depending on the system settings.

    There is no way to tell Android to hide the status bar programmatically when your app is not running in foreground.