heremaps / here-android-sdk-examples

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

Unable to load maps during navigation when the App comes from background. #373

Open binod-techindustan opened 4 years ago

binod-techindustan commented 4 years ago

When running application in background and after device perform some multitasking like openning some others app and then resume the Navigation, maps fail to load and navigation stops. This occurs mostly in low end device having 2-3GB Ram. So how can we restart the map engine and and resume the ongoing navigation?

NazarKacharaba commented 4 years ago

First of all I would suggest using foreground service for background navigation(see example). In that case system will keep your app a bit longer.

1.Resuming navigation HERE SDK does not provide functionality for resuming navigation after app was killed by the OS. If user goes back to the app after some time, to resume navigation you would need to (1)have most recent GPS location, (2)route itself, (3)navigation settings and (4)map state. The (1), (3) and (4) can be achieved on the app side. For the (2) you can use Route.serializeAsync(...) to serialize route so it can be retrieved using Route.deserializeAsync(...)after app was killed.

2.Restarting MapEngine After process was killed by the OS, MapEngine should be re-initialized using MapEngine.init(...) or mapFragment.init(...).