[Java for Android App Development] losaruka:
Hi, thank you for the help.

Now the app runs. But i've got some new problems. In my previous code the layers weren't right insert in the code. I can't insert a whole map. I had to add an extra FeatureLayer.

And now, if I tap on a feature the app stock at a loop, in which the program will look for a featurelayer. i dont know why?!

Another thing is, if I want to get the whole routeoverview, the app will crash. But the code seems to be ok. I don't know, wheres the problem.

Here's the layers:

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

// Retrieve the map and initial extent from XML layout
map = (MapView) findViewById(R.id.map);

// Add tiled layer to MapView
tileLayer = new ArcGISTiledMapServiceLayer(
"tileLAyer");
map.addLayer(tileLayer);

// Add feature layer to MapView
featureLayer = new ArcGISFeatureLayer(
"featureLayer", MODE.ONDEMAND);
map.addLayer(featureLayer);

// Add the route graphic layer (shows the full route)
routeLayer = new GraphicsLayer();
map.addLayer(routeLayer);

// Add the hidden segments layer (for highlighting route segments)
hiddenSegmentsLayer = new GraphicsLayer();
map.addLayer(hiddenSegmentsLayer);

// Make the segmentHider symbol "invisible"
segmentHider.setAlpha(1);

// Get the location service and start reading location. Don't auto-pan
// to center our position
LocationService ls = map.getLocationService();
ls.setLocationListener(new MyLocationListener());
ls.start();
ls.setAutoPan(false);

// Set the directionsLabel with initial instructions.
directionsLabel = (TextView) findViewById(R.id.directionsLabel);
directionsLabel.setText(getString(R.string.route_label));

And here's the loop for the FeatureLayer and the second onSingleTap' for the Routing overview:

map.setOnSingleTapListener(new OnSingleTapListener() {
private static final long serialVersionUID = 1L;

public void onSingleTap(float x, float y) {
if (map.isLoaded()) {
// PopupContainer realisieren.
popupContainer = new PopupContainer(map);
int id = popupContainer.hashCode();
popupDialog = null;
// spinner (Auswahl) anzeigen.
if (progressDialog == null || !progressDialog.isShowing())
progressDialog = ProgressDialog.show(map.getContext(), "", "Rufe Informationen ab...");

// Loop durch jeden Layer in der Basemap.
int tolerance = 20;
// Envelope env = new Envelope(map.toMapPoint(x, y), 20 * map.getResolution(), 20 * map.getResolution());
Layer[] layers = map.getLayers();
count = new AtomicInteger();
for (Layer layer : layers) {
// Wenn der Layer noch nicht geladen wurde oder unsichtbar ist, nichts machen.
if (!layer.isInitialized() || !layer.isVisible())
continue;

if (layer instanceof ArcGISFeatureLayer) {
// Frage den FeatureLayer ab und zeige die Popups.
ArcGISFeatureLayer featureLayer = (ArcGISFeatureLayer) layer;
if (featureLayer.getPopupInfo() != null) {
// Frage den FeatureLayer ab, welcher mit den Popupdefinitionen verknüpft ist.
count.incrementAndGet();
new RunQueryFeatureLayerTask(x, y, tolerance, id).execute(featureLayer);
}
}
}
}
}

////////////////////////////// Routing /////////////////////////////
public void onSingleTap1(float x, float y) {
// Get all the graphics within 20 pixels the click
int[] indexes = hiddenSegmentsLayer.getGraphicIDs(x, y, 20);
// Hide the currently selected segment
hiddenSegmentsLayer.updateGraphic(selectedSegmentID,
segmentHider);

if (indexes.length < 1) {
// If no segments were found but there is currently a route,
// zoom to the extent of the full route
if (curRoute != null) {
map.setExtent(curRoute.getEnvelope(), 250);
directionsLabel.setText(routeSummary);
}
return;
}

// Otherwise update our currently selected segment
selectedSegmentID = indexes[0];
Graphic selected = hiddenSegmentsLayer
.getGraphic(selectedSegmentID);
// Highlight it on the map
hiddenSegmentsLayer.updateGraphic(selectedSegmentID,
segmentShower);
String direction = ((String) selected.getAttributeValue("text"));
double time = ((Double) selected.getAttributeValue("time"))
.doubleValue();
double length = ((Double) selected.getAttributeValue("length"))
.doubleValue();
// Update the label with this direction's information
String label = String.format(
"%s%nTime: %.1f minutes, Length: %.1f miles",
direction, time, length);
directionsLabel.setText(label);
// Zoom to the extent of that segment
map.setExtent(selected.getGeometry(), 50);
}
});

I know that 'onSingleTap1(float x, float y)' doesn't work. But i need to test the code, so in this way I get no error ;)

Hope someone can help :)

Greets