Created
April 28, 2016 10:13
-
-
Save nichtemna/b8f5b30a8e68ae8467413c5af2248fb3 to your computer and use it in GitHub Desktop.
Android app foreground tracker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class App extends Application { | |
| private static LifecycleManager manager = new LifecycleManager(); | |
| @Override | |
| public void onCreate() { | |
| super.onCreate(); | |
| registerActivityLifecycleCallbacks(manager); | |
| } | |
| public static boolean isAppForeground() { | |
| return manager.isActive(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment