Created
June 17, 2019 17:00
-
-
Save eric-romero/1c9ca918389b829b2a9f48dc1973febf to your computer and use it in GitHub Desktop.
This file contains 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 DetectBackgroundApp extends Application { | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
registerActivityLifecycleCallbacks( | |
new ActivityLifecycleCallbacks() { | |
@Override | |
public void onActivityPaused(Activity activity) { | |
BackgroundJobService.enqueueWork(activity); | |
} | |
@Override | |
public void onActivityResumed(Activity activity) { | |
BackgroundJobService.stopWork(); | |
} | |
... rest of the callbacks ... | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment