Hello, I am trying to use the Route_World service but I am not able to get my credentials in the RouteTask I believe. My code is below, I have tried to use UserCredential to bind with the task. I have not entered my temporary token anywhere? Can anyone help me to setup? Thanks public void setupRouteTask() {
mRouteTask = new RouteTask(getApplicationContext(), routeTaskURL);
UserCredential userCredential =
new UserCredential(getApplicationContext().getResources().getString(R.string.arcgis_username),
getApplicationContext().getResources().getString(R.string.arcgis_password));
mRouteTask.setCredential(userCredential);
System.out.println(userCredential.);
final ListenableFuture<RouteParameters> listenableFuture = mRouteTask.createDefaultParametersAsync();
listenableFuture.addDoneListener(new Runnable() {
@Override
public void run() {
try {
if (listenableFuture.isDone()) {
int i = 0;
mRouteParams = listenableFuture.get();
// create stops
Stop stop1 = new Stop(new Point(28.973663, 41.014551, SpatialReferences.getWgs84()));
Stop stop2 = new Stop(new Point(28.968492, 41.017619, SpatialReferences.getWgs84()));
List<Stop> routeStops = new ArrayList<>();
// add stops
routeStops.add(stop1);
routeStops.add(stop2);
mRouteParams.setStops(routeStops);
// set return directions as true to return turn-by-turn directions in the result of getDirectionManeuvers().
mRouteParams.setReturnDirections(true);
// solve
RouteResult result = mRouteTask.solveRouteAsync(mRouteParams).get();
final List routes = result.getRoutes();
mRoute = (Route) routes.get(0);
// create a mRouteSymbol graphic
Graphic routeGraphic = new Graphic(mRoute.getRouteGeometry(), mRouteSymbol);
// add mRouteSymbol graphic to the map
mGraphicsOverlay.getGraphics().add(routeGraphic);
// get directions
// NOTE: to get turn-by-turn directions Route Parameters should set returnDirection flag as true
final List<DirectionManeuver> directions = mRoute.getDirectionManeuvers();
String[] directionsArray = new String[directions.size()];
for (DirectionManeuver dm : directions) {
directionsArray[i++] = dm.getDirectionText();
}
System.out.println("route: " + directionsArray.toString());
}
} catch (Exception e) {
Log.e("xd", e.getMessage());
}
}
});
}
... View more