a period of 5 sec to respond to user input • Any process that takes longer than that leads to bad user experience and possibly ANR error • We have several solutions for running background tasks in android: • Services: Background tasks that are not tied to UI • Loaders: Background tasks that are tied to the UI
background work • Intended for tasks that require a guarantee that the system will run even when the app exits • It is the recommended task scheduler on android for deferrable work with execution guarantee • Part of android jetpack and architecture components • We can execute one off and periodic tasks • It provides a battery-friendly API.
one off and periodic tasks • Support chained tasks with input / output e.g sync data and use output as input for db operation • Define constraints on when to run task • Guarantees task execution even when the app is killed e.g device restart • Follows system health best practices
execute periodically • Minimum repeat interval is 15 min and cannot have initial delay • Before v2.1-alpha02, you cannot have it with an initial delay • It can’t be part of a chain or graph of work • Since it maintains system healthy practices, execution may be delayed because it is subject to battery optimizations such as doze mode