4

I need a way to determine whether ativity active or in the background. I have a service which notifies user, but I want to do it only when activity is inactive. I might use global variables, set them in onStop() for example, but is there any other way?

Konstantin Milyutin
  • 11,946
  • 11
  • 59
  • 85

1 Answers1

5

Have you try to do it with ActivityManager#getRunningAppProcesses() took the idea directly from How to determine if one of my activities is in foreground

Community
  • 1
  • 1
Necronet
  • 6,704
  • 9
  • 49
  • 89