heremaps / here-android-sdk-examples

Java-based projects using the HERE SDK for Android.
Apache License 2.0
145 stars 191 forks source link

Android 8 Oreo compability (background limitation for location updates) #103

Closed Xgamefactory closed 5 years ago

Xgamefactory commented 6 years ago

Will be any support to prevent location update limitations ? currently when app is on background or screen is off here premium sdk cannot receive location updates.

Background Location Limits

https://developer.android.com/about/versions/oreo/background-location-limits.html In an effort to reduce power consumption, Android 8.0 (API level 26) limits how frequently background apps can retrieve the user's current location. Apps can receive location updates only a few times each hour.

There is a suggestion to prevent os limitations

Start a foreground service in your app by calling startForegroundService(). When such a foreground service is active, it appears as an ongoing notification in the notification area.

JH-YVR commented 6 years ago

Thanks @Xgamefactory for raising this. When we analyzed this limitation we concluded that the best approach is (as you mentioned) for applications to implement a foreground service. This has been implemented by developers using the SDK and shown to work well. We will be adding a note to the documentation to highlight the limitation and the workaround.

Xgamefactory commented 6 years ago

This is not just a custom situation it completely affect the navigation logic which is HereMaps core subject. There are many workarounds but other sdks related with location services did add Android os 8 Oreo support with this limitation or at least added in todo list.

romainbenmansour commented 6 years ago

Any news regarding the Here SDK compability with Android 8 Oreo ?

JH-YVR commented 6 years ago

We will update very soon the Turn-by-Turn Navigation example to include a foreground service which addresses the limitation introduced in Oreo. Will post a comment here once it has been updated.

Xgamefactory commented 6 years ago

Thanks for sharing workaround but Android sdk should be compatible with new Android OS this is not a special user oriented case for doing workaround outside sdk.

starand commented 6 years ago

@Xgamefactory That's not a workaround. SDK works properly in case app is setup properly. If you will not add mapservice to the AndroidManifest.xml it will not work. Same here - you have to update the application manifest in order to receive frequent location updates when the app is in background. Implementation of the foreground service requires adding of Notification which is definitely UI staff and it's the application responsibility. You have to customize there notification actions, icons, titles, intents and so on. All of these relates to the app and UI, but not to SDK. SDK is an engine and should now work with UI. ForegroundService cannot be properly added to SDK. Please consider implementation of it on app side.

JH-YVR commented 6 years ago

The Turn by Turn Navigation example has been updated to include use of a Foreground Service to address the restriction on background position updates introduced in Android 8 Oreo.