Check out example codes for "check which activity in focus in android". It will help you in understanding the concepts better.

Code Example 1

public class MyApplication extends Application {

  public static boolean isActivityVisible() {
    return activityVisible;
  }  

  public static void activityResumed() {
    activityVisible = true;
  }

  public static void activityPaused() {
    activityVisible = false;
  }

  private static boolean activityVisible;
}

Learn ReactJs, React Native from akashmittal.com