Background operation are very helpful, while you are needed to perform operation in the background and want to continue with other applications simultaneously.
There are four ways to run background jobs:
Schedule Jobs are jobs while are about run at defined time. For example, if application cache need to be refreshed at defined time. It is used to run task asynchronously.
JobScheduler is a robust way to run background tasks. it is useful for small as well as large asynchronous tasks.
In addition, there are several other facilities available to write jib scheduling tasks. It was first available in Android 5.0, (21), Android 7.0 (24) added ability to trigger job on ContentProvider change.
You can register jobs by specifying their network and timing requirements. It also defer the execution as necessary to comply with Doze and App Standby restrictions. For Android 5.0, it is advised to use job scheduling only.
AlarmManager is another way for scheduling, useful to post notification at scheduled time. So, only use this API to schedule task for a specific time.
Firebase JobDescriptor is like JobScheduler and serves a JobScheduler compatibility layer for devices targeting API of Android 5.0 (21)
SyncAdaptor framework is used to sync data between device and server only. We need authenticator and content provider implementation for this.
Services are written to write task which need log run in the background. Perpetually running task or periodic work should not be written as services.
Exponentially back off is automatically used in JobScheduler and Firebase JobDescriptor. We need to handle this in AlarmManager.
Comments
Post a Comment