2

I'd like to detect if a system dialog (powerdialog and low battery dialog, I think they're the only important one!) has shown. At the end I would like to pause my game, like it's done in Asphalt 7. So there must be a way to detect it, but I haven't found a solution yet.

I know that onPause() will be called if another activity comes to foreground, but it isn't called when the powerdialog becomes visible. And AFAIK I don't have to observe the battery state. I've already read this post, but there's no final answer.

So, what is the best solution to detect when these dialogs are appearing? Do I have to add a broadcast intent?

Community
  • 1
  • 1
Gaeburider
  • 158
  • 1
  • 12

1 Answers1

1

It is strange that the onPause() method is not called when the low-power dialog appears.

However, I would suggest you to monitor the battery level anyway. I have not come across another solution to this.

There is an official tutorial on how to monitor the battery: https://developer.android.com/training/monitoring-device-state/battery-monitoring.html

Al0x
  • 917
  • 2
  • 13
  • 30