AnsweredAssumed Answered

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

Question asked by salecn on Nov 9, 2015
Latest reply on Dec 16, 2015 by MGuo-esristaff

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);

Outcomes