Skip to content

Instantly share code, notes, and snippets.

Just being lazy and crazy

Henry thsaravana

Just being lazy and crazy
View GitHub Profile
thsaravana /
Created Mar 2, 2020
To know if App has gone to background or is in foreground
public class MyApplication implements LifecycleObserver {
public void onCreate() {
public void onStart() {
Log.d("App in foreground");
thsaravana /
Last active Mar 2, 2020
Used to identify when the app goes to foreground or background
public final class AppTransitionStatus implements Application.ActivityLifecycleCallbacks {
private static final long MAX_BACKGROUND_TIME = 2000;
private Timer timer;
private TimerTask task;
private boolean isBackground = true;
private final Transition transition;
public AppTransitionStatus(@NonNull Transition transition) {
You can’t perform that action at this time.