townofsnowflake

app hangs on call of ApplyEdits method

Discussion created by townofsnowflake on Sep 29, 2012
Latest reply on Oct 4, 2012 by agup-esristaff
I???m trying to apply edits in an activity that has a map object, but when the ApplyEdits function is called, the application hangs and doesn't do anything.  After several minutes, I get an Android dialog stating that the application is not responding.  Below is my code.  Thoughts?

Initiate FeatureLayer at beginning of Activity, using method to set UserCredentials:

 ArcGISFeatureLayer fLayer = new ArcGISFeatureLayer("http://<server>/ArcGIS/rest/services/<myfolder>/events/FeatureServer/1", MODE.SNAPSHOT);


Call applyedits() from OnClick() method:

public void onClick(View view){
 
   
FeatureType subType = new FeatureType();
 subType =  editLayer.getTypes()[item.getCatgeory()];
 Toast.makeText(getApplicationContext(), subType.getName() , Toast.LENGTH_SHORT).show(); 
 Point pointwm = GeometryEngine.project(locy,
   locx, webMercator);
 applyEdits(pointwm, subType, editLayer);
  
 
 }

 public void applyEdits(Geometry geometry, FeatureType subType, ArcGISFeatureLayer featureLayer) {
  
    //create a graphic using the template
    Graphic graphic = featureLayer.createFeatureWithType(subType, geometry);
   
  
  
    featureLayer.applyEdits(new Graphic[] { graphic }, null, null, new CallbackListener<FeatureEditResult[][]>() {
   
 
      public void onError(Throwable error) {
        // TODO implement error code
      }

      public void onCallback(FeatureEditResult[][] editResult) {
        // Check the response for success or failure
        if (editResult[0] != null && editResult[0][0] != null && editResult[0][0].isSuccess()) {
         // TODO implement success logic
         Toast.makeText(getApplicationContext(), "event synced" , Toast.LENGTH_SHORT).show(); 
        
      }
      }
      });
  }

Outcomes