Send notifications only when activity is in the background

I need a way to determine if an activity is active or in the background. I have a service that notifies the user, but I want to do this only when activity is inactive. I can use global variables, for example, set them in onStop (), but is there any other way?

+3
source share
1 answer
+5
source

Source: https://habr.com/ru/post/1796222/


All Articles