Select to view content in your preferred language

Route Tracker not receiving TrackingStatusChangedListener

756
4
Jump to solution
09-20-2022 03:07 AM
AnnaSzkibiel
Emerging Contributor

Hello, I'm working on a navigation app. I've done my app based on 'Navigate a route' and 'Navigate in AR samples'. I've managed to calculate and display a route, but when I'm trying to navigate, routeTracker is not receiving any callbacks from TrackingStatusChangedListener and trackingStatus is constantly null.

This is how I'm inititating routeTracker and providing it with current location.

routeTracker = RouteTracker(activity, routeResult, 0, true)
val trackingLocationDataSource = AndroidLocationDataSource(activity)
trackingLocationDataSource.addLocationChangedListener { locationChangedEvent ->
routeTracker.trackLocationAsync(locationChangedEvent.location)
}
trackingLocationDataSource.startAsync()

 I've also tried like this:

routeTracker = RouteTracker(activity, routeResult, 0, true)
mapView.locationDisplay.addLocationChangedListener { locationChangedEvent ->
routeTracker.trackLocationAsync(locationChangedEvent.location)
}

I even made SimulatedLocationDataSource. When I made it like in sample (Navigate a route) locationDisplay didn't appear:

val simulationParameters = SimulationParameters(Calendar.getInstance(), 35.0, 5.0, 5.0)
val simulatedLocationDataSource = SimulatedLocationDataSource().apply { setLocations(routeGeometry, simulationParameters) }
val routeTrackerLocationDataSource = RouteTrackerLocationDataSource(routeTracker, simulatedLocationDataSource)
mapView.locationDisplay.locationDataSource = routeTrackerLocationDataSource
mapView.locationDisplay.addLocationChangedListener { locationChangedEvent ->
routeTracker.trackLocationAsync(locationChangedEvent.location)
}

But wen I made it like this, the location was moving along the route, but routeTracker still didn't receive any callbacks and trackingStatus was still null:

val simulationParameters = SimulationParameters(Calendar.getInstance(), 35.0, 5.0, 5.0)
val simulatedLocationDataSource = SimulatedLocationDataSource().apply { setLocations(routeGeometry, simulationParameters) }
mapView.locationDisplay.locationDataSource = simulatedLocationDataSource
mapView.locationDisplay.addLocationChangedListener { locationChangedEvent ->
routeTracker.trackLocationAsync(locationChangedEvent.location)
}

I passed directly simulatedLocationDataSource to the locationDataSource, without creating RouteTrackerLocationDataSource. So maybe there is a problem with RouteTracker.

I've created a Network Dataset using Arcgis Pro. It supports directions and everything seems to work fine with the network dataset. I'm loading it from a mobile map package. Changing network dataset from the one I created to world routing service: https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World also didn't help.

I'm using 100.15.0 version.

0 Kudos
1 Solution

Accepted Solutions
Shubham_Sharma
Esri Contributor

You can get the license info from their portal using this method:

https://developers.arcgis.com/android/api-reference/reference/com/esri/arcgisruntime/portal/Portal.h...


And then set 

ArcGISRuntimeEnvironment.setLicense(LicenseInfo)

View solution in original post

0 Kudos
4 Replies
Shubham_Sharma
Esri Contributor

@AnnaSzkibiel 

Make sure to add the location data source to the map before calling ".startAsync()". Check out the sample app which uses TrackingStatusChangedListener here: Navigate route with rerouting

// provide the route tacker with the current location of the simulated datasource
simulatedLocationDataSource.addLocationChangedListener {
routeTracker?.trackLocationAsync(it.location)
}
// add a data source for the location display
mapView.locationDisplay.locationDataSource = simulatedLocationDataSource

// start the location data source
mapView.locationDisplay.startAsync()

 

And set up the addTrackingStatusChangedListener like this:

routeTracker = RouteTracker(activity, routeResult, 0, true)
// handle route tracking status changes
routeTracker.addTrackingStatusChangedListener(trackingStatusListener)
...
private val trackingStatusListener: RouteTracker.TrackingStatusChangedListener =
RouteTracker.TrackingStatusChangedListener { trackingStatusChangedEvent ->
// your code here:
updateTrackingStatus(trackingStatusChangedEvent.trackingStatus)
}

 

0 Kudos
AnnaSzkibiel
Emerging Contributor

Thank you @Shubham_Sharma for your response, but that was not the issue. I finally found out, why this wasn't working for me. I've been on a Lite license, for which navigating is restricted.

From my ArcGIS Online account it seems I have 'ArcGIS Runtime Advanced' license. Can I do something to get my license string?

Shubham_Sharma
Esri Contributor

You can get the license info from their portal using this method:

https://developers.arcgis.com/android/api-reference/reference/com/esri/arcgisruntime/portal/Portal.h...


And then set 

ArcGISRuntimeEnvironment.setLicense(LicenseInfo)

0 Kudos
smithse
Occasional Contributor

Thanks for posting this Anna! I have literally spent the better part of a whole day and a half trying to debug and track down code that caused my app to break.

From the sound of things, the app you're building is similar to what I am developing as your posts reflect similar challenges. This post helped me to resolve my issue. As soon as I removed the lite key, I was back to a working app.... with a ton of additional 'debug' code that I can now get rid of. Kudos to you 🙂

Sean