Reputation: 1
Android sdk version :(com.google.android.libraries.navigation:navigation:6.0.0)
target device:An Android pad without a GPS hardware module, capable of WiFi positioning
when i use navigation demo,i set a destination,code interface
navigator.setDestination
return RouteStatus.LOCATION_DISABLED ,can not return RouteStatus.OK
but now
onGpsAvailabilityUpdate return true
withNavigatorAsync {
Log.d(TAG,"waypoint = "+waypoint?.position)
val pendingRoute = navigator.setDestination(waypoint)
// Set an action to perform when a route is determined to the destination
pendingRoute?.setOnResultListener { code ->
when (code) {
RouteStatus.OK -> {
// Hide the toolbar to maximize the navigation UI
actionBar?.hide()
// Enable voice audio guidance (through the device speaker)
navigator.setAudioGuidance(Navigator.AudioGuidance.VOICE_ALERTS_AND_GUIDANCE)
// Simulate vehicle progress along the route (for demo/debug builds)
if (BuildConfig.DEBUG) {
navigator.simulator.simulateLocationsAlongExistingRoute(
SimulationOptions().speedMultiplier(5f)
)
}
// Start turn-by-turn guidance along the current route
navigator.startGuidance()
}
RouteStatus.ROUTE_CANCELED -> showToast("Route guidance cancelled.")
RouteStatus.NO_ROUTE_FOUND,
RouteStatus.NETWORK_ERROR ->
// TODO: Add logic to handle when a route could not be determined
showToast("Error starting guidance: $code")
else -> showToast("Error starting guidance: $code")
}
}
}
NavigationApi.getRoadSnappedLocationProvider(application).addLocationListener(object :
RoadSnappedLocationProvider.GpsAvailabilityEnhancedLocationListener {
override fun onLocationChanged(p0: Location?) {
Log.d(TAG,"onLocationChanged location = $p0")
}
override fun onRawLocationUpdate(p0: Location?) {
Log.d(TAG,"onRawLocationUpdate location = $p0")
}
override fun onGpsAvailabilityUpdate(p0: Boolean) {
Log.d(TAG,"onGpsAvailabilityUpdate location = $p0")
}
})
onGpsAvailabilityUpdate callback true
Upvotes: 0
Views: 51