• Don’t waste battery unnecessarily • App should still work correctly even in Doze mode or in App Standby • Scheduling repeated work is quite a headache with 3 different APIs all doing similar things
• Run job only on an unmetered network and only if device is charging • Don’t wake up the device to sync data • JobScheduler and GCM Network Manager work best, AlarmManager is fallback
Manager and AlarmManager • All API 24 features supported • Automatically chooses best API to run a job • Less boilerplate, e.g. no manifest entry needed • No reflection used • Maintained and improved continuously • … and more
final String TAG = "SyncJob"; @NonNull @Override protected Result onRunJob(Params params) { new SyncEngine().syncReminders(); return Result.SUCCESS; } }