How do games detect lost focus (such as opening notification pane) on Android

Viewed 29

For example in game Asphalt 9, when the player swiping down the notification, the game is paused.

I have tried onPause, but it only fired when I switch to another app / activity. It doesn't detect something like opening the notification pane.

1 Answers

You can override onWindowFocusChanged method of activity. It will loose focus when user open notification bar or some system dialog show up.

Related