Search code examples
androidandroid-activitywindowfocus

Window popups or ads breaking fullscreen\immersive mode. Are there any ways to prevent this?


When my app is in immersive mode, and if an ad or third party window pops up during this time, it completely breaks the mode and my navigation bar will appear, and refuses to disappear.

I've tried reintroducing the full screen flags each time the window loses focus but it simply does not work. This app would be an example of a popup source: https://play.google.com/store/apps/details?id=com.nlucas.popupnotificationslite&hl=en

I've seen numerous apps being able to ignore such events without procing the navbar. Can anyone point me in the right direction? I've worked with numerous people and everyone came up short.

It seems the problem is that these popups\overlaid windows "steal" the focus off my activity and refuses to let it go until it's cleared or dismissed. Only then will the navbar disappear on its own a few seconds later.


Solution

  • If another app comes to the foreground, there's nothing your app can do to stop it from doing whatever it wants. Immersive mode doesn't also give you "exclusive" access to the device's UI. You still have to share the Android device with the other apps.

    In the absence of an example of an advertising library (no way I'm using any shading ad SDK - hate those things!) I'm going to say that these libraries could also be starting activities that come to top of your activity stack, which would also break immersive mode because those activities probably won't be requesting it themselves. Sorry. :-(