Friday, December 14, 2018

Android: Changes for Location updates in Oreo

1. Background apps will receive location updates only a few times each hour (the location update interval may be adjusted in the future based on system impact and feedback from developers).
2. Foreground apps are not affected by these limits
3. These background limits apply to all apps running on an O device, regardless of the target SDK.
4. Apps targeting of O are further subject to limits on services started in the background. For these reasons, apps targeting O should not use PendingIntent.getService() when requesting location updates. Instead they should use PendingIntent.getBroadcast().

Below are the alternative to consider

1. Use foreground updates
Request updates in the foreground. This means requesting and removing updates as part of the activity lifecycle(request in onResume() and remove in onPause()) Apps running in the foreground are not subject to any location limits on O devices.

2. Use a foreground service. Request updates using a foreground service. This involves displaying a non-dismissible, persistent notification to users. While this may make sense for some use cases, developers should be thoughtful about using foreground services and what the messaging the user should see.

3. Use Geo fencing : If the use case relies on the device entering, dwelling, or existing a particular area of interest, this API provides a performant way to get these notifications. This approach is more efficient that checking location at regular intervals.

Below are some more tips when requesting location.

1. Use bactched location updates :

references:

No comments:

Post a Comment