Search code examples
androidandroid-activityshow-hideforegroundbackground-foreground

Is possible to check running application currently is showing or not on Android device


I'm working with Receiver and I can detect Wifi state changes in Wifi Setting System.

But I need to know specified application is showing or not to do more thing,

ex. if specified application was hide in Background, do nothing, and if it was showing for user to integrate, I will do something.

People who know how to check specified application was running is showing or not,

Please help me,

p/s :

  • I have 1 Receiver and 1 Activity (is "specified Application" as I mentioned)

  • I can integrate in onReceive method, it means I know how to receive signal.

Thanks.

SOLUTION

Okay, thank you,

I know how to check.

I need stored public static boolean in onPause method, to indicate current is invisible state.

And when onResume method was called, the above boolean will be in Visible state.

How to check if activity is in foreground or in visible background?


Solution

  • Okay, thank you,

    I know how to check.

    I need to store public static boolean in onPause() method, to indicate its currently in invisible state.

    And when onResume method is called, the above boolean will be in Visible state.

    How to check if activity is in foreground or in visible background?