Source:
<code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mMapView = findViewById(R.id.mapView); mMapView.getSelectionProperties().setColor(Color.RED); final ArcGISMap map = new ArcGISMap(Basemap.createStreets()); map.setInitialViewpoint(new Viewpoint(new Envelope(-1131596.019761, 3893114.069099, 3926705.982140, 7977912.461790, SpatialReferences.getWebMercator()))); mMapView.setMap(map); final ServiceFeatureTable serviceFeatureTable = new ServiceFeatureTable(getString(R.string.gdp_per_capita_url)); final FeatureLayer featureLayer = new FeatureLayer(serviceFeatureTable); map.getOperationalLayers().add(featureLayer); mMapView.setOnTouchListener(new DefaultMapViewOnTouchListener(this, mMapView) { @Override public boolean onSingleTapConfirmed(MotionEvent motionEvent) { featureLayer.clearSelection(); <START> Point screenPoint = new Point(Math.round(motionEvent.getX()), <END> Math.round(motionEvent.getY())); int tolerance = 10; ListenableFuture<IdentifyLayerResult> identifyLayerResultFuture = mMapView.identifyLayerAsync( featureLayer, screenPoint, tolerance, false, -1 ); identifyLayerResultFuture.addDoneListener(() -> { try { IdentifyLayerResult identifyLayerResult = identifyLayerResultFuture.get(); int counter = 0; for (GeoElement element : identifyLayerResult.getElements()) { if (element instanceof Feature) { Feature feature = (Feature) element; featureLayer.selectFeature(feature); counter++; Log.d(TAG, "Selection #: " + counter + " Table name: " + feature.getFeatureTable().getTableName()); } } Toast.makeText(getApplicationContext(), counter + " features selected", Toast.LENGTH_SHORT).show(); } catch (Exception e) { Log.e(TAG, "Select feature failed: " + e.getMessage()); } }); return super.onSingleTapConfirmed(motionEvent); } }); }</code><technical_language>line</technical_language>

Target:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mMapView = findViewById(R.id.mapView); mMapView.getSelectionProperties().setColor(Color.RED); final ArcGISMap map = new ArcGISMap(Basemap.createStreets()); map.setInitialViewpoint(new Viewpoint(new Envelope(-1131596.019761, 3893114.069099, 3926705.982140, 7977912.461790, SpatialReferences.getWebMercator()))); mMapView.setMap(map); final ServiceFeatureTable serviceFeatureTable = new ServiceFeatureTable(getString(R.string.gdp_per_capita_url)); final FeatureLayer featureLayer = new FeatureLayer(serviceFeatureTable); map.getOperationalLayers().add(featureLayer); mMapView.setOnTouchListener(new DefaultMapViewOnTouchListener(this, mMapView) { @Override public boolean onSingleTapConfirmed(MotionEvent motionEvent) { featureLayer.clearSelection(); Point screenPoint = new Point(Math.round(motionEvent.getX()), Math.round(motionEvent.getY())); int tolerance = 10; ListenableFuture<IdentifyLayerResult> identifyLayerResultFuture = mMapView .identifyLayerAsync(featureLayer, screenPoint, tolerance, false, -1); identifyLayerResultFuture.addDoneListener(() -> { try { IdentifyLayerResult identifyLayerResult = identifyLayerResultFuture.get(); int counter = 0; for (GeoElement element : identifyLayerResult.getElements()) { if (element instanceof Feature) { Feature feature = (Feature) element; featureLayer.selectFeature(feature); counter++; Log.d(TAG, "Selection #: " + counter + " Table name: " + feature.getFeatureTable().getTableName()); } } Toast.makeText(getApplicationContext(), counter + " features selected", Toast.LENGTH_SHORT).show(); } catch (Exception e) { Log.e(TAG, "Select feature failed: " + e.getMessage()); } }); return true; } }); }