detect app visibility status
-
auto detect the app go to background
-
auto detect the app go to foreground
the screen turn around is also in consideration, you don't need to handle it your self
AppVisibilityDetector implement in one java file, download AppVisibilityDetector.java and add to you project may be the easiest way to use. I'll build a aar for gradle used later.
used examples:
AppVisibilityDetector.init(MyApp.this, new AppVisibilityCallback() { @Override public void onAppGotoForeground() { //app is from background to foreground } @Override public void onAppGotoBackground() { //app is from foreground to background } });
the MyApp is your Application class.
public class MyApp extends Application { ... }
This library is distributed under the Apache 2.0 license.