PDA

View Full Version : [Android] Can't get navigation informations



Beplace
05.07.2015, 16:12
Hello,

We, a friend and I, are currently developing a GPS app on both iOS and Android, including a navigation system. So the navigation works fine on iOS, the street name, advice visual, current speed and all are displayed, meanwhile on Android I can't retrieve the current state of the navigation (using the SKNavigationState class), all the variable is showing "null" or weird values like "-1545784588" (n.b. : this is not the real value). I've tried everything, and it's seems like I will lose a lot of time trying to "rewrite" the class from stratch, so I'm asking this question : is anyone already have this issue, if so how can I fix it ?

Adela_Silvia
06.07.2015, 08:25
Hello,

Can you please share the code snippets that you are using (Android)?

Beplace
06.07.2015, 11:29
Thanks for the answer

The whole class is pretty big in size so i'll put just the interesting part.

I'm using a button to start the navigation after calcutating the route between my current position and a geocoded adress

So here is the button code :




itineraireButton.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {

SKRouteSettings route = new SKRouteSettings();

route.setStartCoordinate(TPLocation.getLocation()) ;
route.setDestinationCoordinate(TPPlace.getLocation ());

route.setNoOfRoutes(1);

route.setRouteMode(SKRouteSettings.SKRouteMode.CAR _FASTEST);

route.setRouteExposed(true);

SKRouteManager.getInstance().setRouteListener(MapA ctivity.this);

SKRouteManager.getInstance().calculateRoute(route) ;
}
});




And the RouteListener implementation :




@Override
public void onAllRoutesCompleted() {
launchNavigation();
}

// the others methods to be overridden are empty



The launchNavigation method and the implemented method





private void launchNavigation() {

SKNavigationSettings navigationSettings = new SKNavigationSettings();

navigationSettings.setNavigationType(SKNavigationT ype.SIMULATION); // --> doesnt work either with real or simulation

SKNavigationManager navigationManager = SKNavigationManager.getInstance();
navigationManager.setMapView(mapView);

navigationManager.setNavigationListener(this);


navigationManager.startNavigation(navigationSettin gs);
navigationInProgress = true;
}


@Override
public void onUpdateNavigationState(SKNavigationState navigationState) {
Log.d("NAVIGATION STATE", navigationState.toString());
}



The logs shows me this :




07-06 11:21:41.357: D/NAVIGATION STATE(23939): SKNavigationState [adviceID=-1, currentSpeed=8.48764990139376E-59, currentSpeedLimit=0.0, countryCode=, lastAdvice=false, showSignPost=false, currentAdviceCurrentStreetName=, currentAdviceNextStreetName=, currentAdviceCurrentOsmStreetType=UNDEFINED, currentAdviceNextOsmStreetType=UNDEFINED, currentAdviceDistanceToAdvice=-1596904064, currentAdviceTimeToDestination=-1597223088, currentAdviceDistanceToDestination=-1596904256, currentAdviceVisualAdviceFile=, currentAdviceAudioAdvices=[None], currentAdviceExitNumber=, nextAdviceCurrentStreetName=, nextAdviceNextStreetName=, nextAdviceDistanceToAdvice=-1596939744, nextAdviceVisualAdviceFile=, nextAdviceCurrentOsmStreetType=UNDEFINED, nextAdviceNextOsmStreetType=UNDEFINED, distanceToDestination=0.0, firstCrossingDescriptor=SKCrossingDescriptor [crossingType=0, routeAngle=0.0, turnToRight=false, directionUK=false, allowedRoutesAngles=null, forbiddenRoutesAngles=null], secondCrossingDescriptor=SKCrossingDescriptor [crossingType=0, routeAngle=0.0, turnToRight=false, directionUK=false, allowedRoutesAngles=null, forbiddenRoutesAngles=null], adviceInstruction=, viaPointsInfo=null]




I've provided everything I found interesting, if you need anything else let me know, and thanks again for the help.

dandronic
07.07.2015, 14:45
Looking at the code you provided, everything seems ok (I can't spot any problems).

In the demo project I've inserted a log in one of the onUpdateNavigationState listeners (i.e. the one attached to the Routing and navigation menu entry), and it behaves as expected (i.e. I get real results)


[adviceID=4, currentSpeed=16.666666666666668, currentSpeedLimit=0.0, countryCode=US, lastAdvice=false, showSignPost=true, currentAdviceCurrentStreetName=19th Street, currentAdviceNextStreetName=Pennsylvania Avenue, currentAdviceCurrentOsmStreetType=RESIDENTIAL, currentAdviceNextOsmStreetType=SECONDARY, currentAdviceDistanceToAdvice=6, currentAdviceTimeToDestination=424, currentAdviceDistanceToDestination=8519, currentAdviceVisualAdviceFile=/data/data/com.skobbler.sdkdemo/files/SKMaps//Advisor/Visual/772372/0.png, currentAdviceAudioAdvices=[now, turn_left, onto, Pennsylvania Avenue], currentAdviceExitNumber=, nextAdviceCurrentStreetName=Pennsylvania Avenue, nextAdviceNextStreetName=Mariposa Street, nextAdviceDistanceToAdvice=81, nextAdviceVisualAdviceFile=, nextAdviceCurrentOsmStreetType=SECONDARY, nextAdviceNextOsmStreetType=SECONDARY, distanceToDestination=8519.0, firstCrossingDescriptor=SKCrossingDescriptor [crossingType=0, routeAngle=180.0, turnToRight=false, directionUK=false, allowedRoutesAngles=[91.0, -1.0], forbiddenRoutesAngles=null], secondCrossingDescriptor=SKCrossingDescriptor [crossingType=0, routeAngle=2.0, turnToRight=false, directionUK=false, allowedRoutesAngles=[90.0], forbiddenRoutesAngles=null], adviceInstruction=now turn left onto Pennsylvania Avenue , viaPointsInfo=null]
07-08 00:42:21.461 13159-13159/? D/Navigation state demo﹕ SKNavigationState [adviceID=4, currentSpeed=16.666666666666668, currentSpeedLimit=0.0, countryCode=US, lastAdvice=false, showSignPost=true, currentAdviceCurrentStreetName=19th Street, currentAdviceNextStreetName=Pennsylvania Avenue, currentAdviceCurrentOsmStreetType=RESIDENTIAL, currentAdviceNextOsmStreetType=SECONDARY, currentAdviceDistanceToAdvice=1, currentAdviceTimeToDestination=424, currentAdviceDistanceToDestination=8514, currentAdviceVisualAdviceFile=/data/data/com.skobbler.sdkdemo/files/SKMaps//Advisor/Visual/772372/0.png, currentAdviceAudioAdvices=[now, turn_left, onto, Pennsylvania Avenue], currentAdviceExitNumber=, nextAdviceCurrentStreetName=Pennsylvania Avenue, nextAdviceNextStreetName=Mariposa Street, nextAdviceDistanceToAdvice=81, nextAdviceVisualAdviceFile=, nextAdviceCurrentOsmStreetType=SECONDARY, nextAdviceNextOsmStreetType=SECONDARY, distanceToDestination=8514.0, firstCrossingDescriptor=SKCrossingDescriptor [crossingType=0, routeAngle=180.0, turnToRight=false, directionUK=false, allowedRoutesAngles=[91.0, -1.0], forbiddenRoutesAngles=null], secondCrossingDescriptor=SKCrossingDescriptor [crossingType=0, routeAngle=2.0, turnToRight=false, directionUK=false, allowedRoutesAngles=[90.0], forbiddenRoutesAngles=null], adviceInstruction=now turn left onto Pennsylvania Avenue , viaPointsInfo=null]
07-08 00:42:23.831 13159-13159/? D/Navigation state demo﹕ SKNavigationState [adviceID=7, currentSpeed=16.666666666666668, currentSpeedLimit=0.0, countryCode=US, lastAdvice=false, showSignPost=true, currentAdviceCurrentStreetName=Pennsylvania Avenue, currentAdviceNextStreetName=Mariposa Street, currentAdviceCurrentOsmStreetType=SECONDARY, currentAdviceNextOsmStreetType=SECONDARY, currentAdviceDistanceToAdvice=248, currentAdviceTimeToDestination=421, currentAdviceDistanceToDestination=8477, currentAdviceVisualAdviceFile=/data/data/com.skobbler.sdkdemo/files/SKMaps//Advisor/Visual/772372/1.png, currentAdviceAudioAdvices=[in_open, 200_meters, turn_right, onto, Mariposa Street], currentAdviceExitNumber=, nextAdviceCurrentStreetName=Mariposa Street, nextAdviceNextStreetName=I280 , nextAdviceDistanceToAdvice=50, nextAdviceVisualAdviceFile=, nextAdviceCurrentOsmStreetType=SECONDARY, nextAdviceNextOsmStreetType=MOTORWAY_LINK, distanceToDestination=8477.0, firstCrossingDescriptor=SKCrossingDescriptor [crossingType=0, routeAngle=1.0, turnToRight=false, directionUK=false, allowedRoutesAngles=[94.0, 180.0], forbiddenRoutesAngles=null], secondCrossingDescriptor=SKCrossingDescriptor [crossingType=0, routeAngle=2.0, turnToRight=false, directionUK=false, allowedRoutesAngles=[90.0], forbiddenRoutesAngles=null], adviceInstruction=in 200 meters turn right onto Mariposa Street , viaPointsInfo=null]
07-08 00:42:24.136 13159-13159/? D/Navigation state demo﹕ SKNavigationState

Can you try and replicate your issue in our demo app?

Beplace
07.07.2015, 17:00
Yes I've got real results too with the demo app. I kinda solved my issue about an hour ago by copying the whole demo project, rename it with my app name and get rid of everything I didn't wanted/use, fixed some packages/dependencies error and launched, and hooray I finally got real values. I still don't know where the problem come from, I guess it's some project issue or something, but for everyone in the future who encounter the similar issue I suggest you do the same I did, for the moment, at least it will save you a lot of time. And thanks of course for the help and the answer provided.

dandronic
08.07.2015, 09:28
We're glad to hear you managed to get it to work!

gabri15
19.07.2015, 12:47
Yes I've got real results too with the demo app. I kinda solved my issue about an hour ago by copying the whole demo project, rename it with my app name and get rid of everything I didn't wanted/use, fixed some packages/dependencies error and launched, and hooray I finally got real values. I still don't know where the problem come from, I guess it's some project issue or something, but for everyone in the future who encounter the similar issue I suggest you do the same I did, for the moment, at least it will save you a lot of time. And thanks of course for the help and the answer provided.

I'm actually having the same problem here, I posted it in http://stackoverflow.com/questions/31476067/sktools-use-only-navigation-ui-issues and I couldn't make it work as you did, It's a very large project and I cannot dump everything and start again.

As I post in Stack Overflow, I'm using SKTools for doing the navigation, but the route calculation is done by myself. I calculate the route in one activity, set the route by his unique ID, and later on I start the other activity which launches the navigation. The route is correctly displayed on screen, but all the advices are like yours, just trash data.

Any thoughts on this?

Adela_Silvia
21.07.2015, 10:34
Could you please send us your demo project, so that we can take a closer look at your code?

gabri15
27.07.2015, 16:20
I found out the issue, if the SKAdvisorSettings are not properly configured (like the path to the sources for the advices) you get that kind of error, It could be useful if SKAdvisorSettings throws some kind of error to let the developer know that something is wrong with the configuration.

Adela_Silvia
27.07.2015, 16:33
Thanks gabri15 for adding this solution to the thread

faeem.ali
30.07.2015, 18:34
I am having the same problem for the last few days. Having read gabri15's response, I explicitly went and hardcoded the SKAdvisorSettings paths but it still doesn't work. I've posted a detailed explanation at http://stackoverflow.com/questions/31722784/onupdatenavigationstate-error

Here's my SKAdvisorSettings code:

final SKAdvisorSettings advisorSettings = new SKAdvisorSettings();
advisorSettings.setLanguage(SKAdvisorSettings.SKAd visorLanguage.LANGUAGE_EN);
advisorSettings.setAdvisorConfigPath(SkobblerInit. getMapResDirPath(VayaDecoNavigateActivity.this) + "/Advisor");
advisorSettings.setResourcePath(SkobblerInit.getMa pResDirPath(VayaDecoNavigateActivity.this) + "/Advisor/Languages");
advisorSettings.setAdvisorVoice("en");
advisorSettings.setAdvisorType(SKAdvisorSettings.S KAdvisorType.AUDIO_FILES);
SKRouteManager.getInstance().setAudioAdvisorSettin gs(advisorSettings);

onUpdateNavigationState() is always called, just with no/garbage data.