Skip to content

Instantly share code, notes, and snippets.

@eric-romero
Created June 17, 2019 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eric-romero/1c9ca918389b829b2a9f48dc1973febf to your computer and use it in GitHub Desktop.
Save eric-romero/1c9ca918389b829b2a9f48dc1973febf to your computer and use it in GitHub Desktop.
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