Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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