Click Android device screen, the value is null ids variables, don't get data? Please help analyze possible causes! Thank you teacher!

3435
1
11-09-2015 06:09 AM
liutao
by
New Contributor II

question:Click Android device screen, the value is null ids variables, don't get  data? Please help analyze possible causes! Thank you teacher!

1、develop environment:  ArcGIS for Android  10.2.4    Eclipise     +  ArcGIS Map 10.3  share   runtime  GeoDatabase

2、Code

  public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);      
  mMapView = new MapView(this); 
  mMapView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT)); 
  String  urltpk=Environment.getExternalStorageDirectory().getPath()+"/map/map2.tpk"; 
  ArcGISLocalTiledLayer  arm= new ArcGISLocalTiledLayer(urltpk);  
        mMapView.addLayer(arm,0);   
        String  urldata= Environment.getExternalStorageDirectory().getPath()+"/map/map2.geodatabase";       
        try {
            db=new Geodatabase(urldata);       
         } catch (FileNotFoundException e) {
             e.printStackTrace();
         }
       
        featureTable= db.getGeodatabaseTables().get(0); 
        featureLayer= new FeatureLayer(featureTable);       
        mMapView.addLayer(featureLayer,1);      
       
        mMapView.setOnSingleTapListener(new OnSingleTapListener() {

   public void onSingleTap(float x, float y) {
    long[] ids = featureLayer.getFeatureIDs(x,y,30);     // ids is empty, get less data, please help Analysis reason?
                if (ids.length > 0 && ids != null) {               
                Feature feature = featureLayer.getFeature(ids[0]);             
                }
   }
  });
         setContentView(mMapView);

0 Kudos
1 Reply
MengyiGuo
Occasional Contributor

getFeatureIDs(float x, float y, int tolerance) Identifies the features for the specified device screen coordinates and search tolerance

Could you please test getFeature(long oid) to get the Feature specified by its ID?

In this way we can test if the featurelayer is added correctly to the map and narrow down the issue.