If ???Apply Edits??? method used on second Feature Layer, then after pausing and resuming the application, features load, but don???t appear.
public class BlablaESRIActivity extends Activity {
public MapView mapView;
BingMapsLayer tLayer = null;
ArcGISFeatureLayer fLayer = null;
ArcGISFeatureLayer logTable = null;
Graphic currentGraphic = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
mapView = (MapView)findViewById(R.id.mapview);
mapView.setOnStatusChangedListener(mapOnStatusChangedListener);
tLayer = new BingMapsLayer("vjhadbfabsdffv...", MapStyle.Road);
mapView.addLayer(tLayer);
mapView.setOnSingleTapListener(mapOnSingleTapListener);
}
@Override
protected void onDestroy() {
super.onDestroy();
mapView.recycle();
}
@Override
protected void onPause() {
super.onPause();
mapView.pause();
}
@Override
protected void onResume() {
super.onResume();
mapView.unpause();
}
private OnStatusChangedListener mapOnStatusChangedListener = new OnStatusChangedListener() {
private static final long serialVersionUID = 1L;
public void onStatusChanged(Object source, STATUS status) {
if (source == mapView && status == STATUS.INITIALIZED) {
fLayer = new ArcGISFeatureLayer("http://.../ArcGIS/rest/services/POIs/FeatureServer/0",MODE.ONDEMAND);
mapView.addLayer(fLayer);
logTable = new ArcGISFeatureLayer("http://.../ArcGIS/rest/services/POIs/FeatureServer/1", new Options(),c);
}
}
};
private OnSingleTapListener mapOnSingleTapListener = new OnSingleTapListener() {
private static final long serialVersionUID = 1L;
public void onSingleTap(float x, float y) {
if (currentGraphic == null) {
int[] graphicIDs = fLayer.getGraphicIDs(x, y, 20);
if (graphicIDs == null) return;
if (graphicIDs.length == 0) return;
currentGraphic = fLayer.getGraphic(graphicIDs[0]);
} else {
Point p = (Point) currentGraphic.getGeometry();
p.setXY(mapView.toMapPoint(x, y).getX(), mapView.toMapPoint(x, y).getY());
saveCurrentPOI();
}
}
};
public void saveCurrentPOI() {
if (currentGraphic == null) return;
fLayer.applyEdits(null, null, new Graphic[] { currentGraphic }, null);
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put("LANDMARK_NAME", "name");
attributes.put("LANDMARK_X", ((Point) currentGraphic.getGeometry()).getX());
attributes.put("LANDMARK_Y", ((Point) currentGraphic.getGeometry()).getY());
Graphic newLogRecord = new Graphic(null, null, attributes, null);
//If ???Apply Edits??? method used on this Feature Layer, then after pausing and resuming the application, fLayer points load, but don???t appear.
logTable.applyEdits(new Graphic[] { newLogRecord }, null, null, null);
currentGraphic = null;
}
}