Energy Patterns for Mobile Apps

← show all patterns

Batch Operations

Batch Operations

Batch multiple operations instead of putting the device into an active state many times.

Context

1) Background tasks can be expensive. A given task needs to be eventually executed, but it does not need to be executed at a specific time. 2) Executing operations separately might lead to tail energy consumptions.

Solution

Bundle multiple operations in a single one.

Example

Use Job Scheduling APIs (e.g., `android.app.job.JobScheduler`, Firebase JobDispatcher) that manage multiple background tasks occurring in a device. These APIs will guarantee that the device will exit when there is a reasonable amount of work to do. It combines several multiple tasks to prevent the device from constantly exiting sleep mode (or doze mode). Other examples: execute only if another task is using the required resource; ask for location while setting 'notification responsiveness' with a reasonable delay; try to collect location data when other apps are collecting it as well.

References

Occurrences

Android

Issues
Pull Requests
Commits

iOS

Issues
No issues.
Pull Requests
No pull requests.
Commits