简体   繁体   中英

How to detect and dismiss system alert dialog

I have an app that shows video all the time in fullscreen mode. So I have a signle activity and SurfaceView on it. There's no access to the screen or buttons of the device, so all I have is just a monitor showing video.

The problem is that from time to time my mobile operator sends an adverts that open up on device as alert dialog. This dialogs are shown above my activity and I need to dismiss them somehow. Or maybe somehow forbid the system to open this type of dialogs.

Is it possible on android and how to do this?

You can't dismiss dialogs belonging to the system or 3rd party apps, but depending on your setup and needs you do have a couple other solutions:

  • programmatically turn of the mobile network connectivity (or put the phone completely into airplane mode) while the video is playing, so you don't get any other data (sms or any other kind) from the network

  • when your activity loses focus ( onPause event), bring it back to focus or relaunch it while preserving current video time

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM