Ankit Kumar

Ankit Kumar

  • NA
  • 1
  • 2.9k

Development ArcGIS Application for android

May 5 2013 8:18 AM
Hello, I am a new developer for android and i am developing ArcGIS Application for Android. I am using the Eclipse IDE, JDK and JRE for java 7, ADT Bundle 21.1.0, Android SDK for Window (64 Bits) and ArcGIS Runtime SDK 10.1 Plugin and the I am also using Android ADT bundle in other machine with ArcGIS Runtime plugin. MY problem is When i am trying to add the ArcGIS Feature Layer its show the error  like as 
StringwmsURL cannot be resolved to a variable   and
wmsURL cannot be resolved to a variable
.....  after that when when i am adding the callout its show some error like as-  xml cannot be resolved or is not a field and when i am add the popup in specific layer of web map its show more error like as rename the variable and variable cannot be resolve.
If my code is incorrect what is the correct code and can you provide me.

The application code taken from the ArcGIS tutorial and the link of tutorial are:
http://resources.arcgis.com/en/help/android-sdk/concepts/index.html#/Welcome_to_the_help_for_ArcGIS_Runtime_SDK_for_Android/011900000024000000/


code for Feature layer:

String URL = "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer/0";
            ArcGISFeatureLayer fLayer = new ArcGISFeatureLayer(URL, MODE.ONDEMAND);
           
            http://<server:port>/<instance>/services/<service>/MapServer/WMSServer
               
                StringwmsURL = "http://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StateCityHighway_USA/MapServer/WMSServer";
       
            WMSLayer wmsLayer = new WMSLayer(wmsURL);
            map.addLayer(wmsLayer);

            String[] visibleLayers = {"ushigh", "counties"};
            wmsLayer.setVisibleLayer(visibleLayers);

            WMSLayerInfo[] wmsLayerInfo = wmsLayer.getLayers();

Code for callout:

Object callout;
            callout.setStylefindViewByXML(R.xml.countrypop);
            Graphic gr;
            String countyName = (String) gr.getAttributeValue("NAME");
            String countyPop = gr.getAttributeValue("POP07_SQMI").toString();
            // Sets custom content layout to callout.                                callout.setContent(loadView(countyName,countyPop));

code for Popup: its show more error show i cannot give the colour of error.
MapView map = ;
PopupContainer popupContainer = new PopupContainer(map);
MapView map = ;
Layer layer = ;
int  subLayerId = ;
Graphic graphic = ;
……
Popup popup = layer.createPopup(map, subLayerId, graphic);
MapView map = ;
ArcGISFeatureLayer featureLayer = ;
Graphic graphic = ;
……
Popup popup = featureLayer.createPopup(map, 0, graphic);
Popup popup = ;  // create popup
PopupContainer popupContainer = ;

popupContainer.addPopup(popup); // add popup to popup container
// Create a dialog for the popups and display it.
PopupDialog popupDialog = new PopupDialog(map.getContext(), popupContainer);

...

// A customize full screen dialog.
private class PopupDialog extends Dialog {
  private PopupContainer popupContainer;
 
  public PopupDialog(Context context, PopupContainer popupContainer) {
		  super(context, android.R.style.Theme);
		  this.popupContainer = popupContainer;
	 }
	  
	 @Override
	 protected void onCreate(Bundle savedInstanceState) {
		  super.onCreate(savedInstanceState);
		  LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		 	LinearLayout layout = new LinearLayout(getContext());
			 layout.addView(popupContainer.getPopupContainerView(), android.widget.LinearLayout.LayoutParams.FILL_PARENT, android.widget.LinearLayout.LayoutParams.FILL_PARENT);
			 setContentView(layout, params);
		}
	  
}
MapView map = ;
ArcGISTiledMapServiceLayer tiledLayer = ;
ArcGISLayerInfo layerInfo = ;
Envelope env = ;
Popup popup;

int layerID = layerInfo.getId();
String layerUrl = tiledLayer.getQueryUrl(layerID);
if (layerUrl == null)
  layerUrl = tiledLayer.getUrl() + "/" + layerID;
ArcGISPopupInfo popupInfo = tiledLayer.getPopupInfo(layerID);
Query query = new Query();
query.setInSpatialReference(sr);
query.setOutSpatialReference(sr);
query.setGeometry(env);
query.setOutFields(new String[] {"*"});  						
QueryTask queryTask = new QueryTask(layerUrl);
try {
  FeatureSet results = queryTask.execute(query);	
  for (Graphic graphic : results.getGraphics()) {
    popup = tiledLayer.createPopup(map, layerID, graphic);
    popupContainer.addPopup(popup);
  }
} catch (Exception e) {
  e.printStackTrace();
}
// Add Popup
 Popup popup = featureLayer.createPopup(map, 0, graphic);
 popup.setEditMode(true);
 popupContainer.addPopup(popup);
Popup popup = ;

Graphic gr = popup.getGraphic();
Map<String, Object> attributes = gr.getAttributes();
Map<String, Object> updatedAttrs = popup.getUpdatedAttributes();
for (Entry<String, Object> entry : updatedAttrs.entrySet()) {
  attributes.put(entry.getKey(), entry.getValue());
}
Graphic newgr = new Graphic(gr.getGeometry(), null, attributes, null);
Popup popup = ;
popup.setPopupListener(this);
popup.setEditMode(true);
……
@Override
public void onPopupModified() {
  Log.i(IOUtils.TAG, "onPopupModified");
  mModified = true;
  View titleView = getPopup().getLayout().getTitleView();
  if (titleView != null && titleView instanceof ArcGISTitleView) {
    Symbol symbol = ((ArcGISTitleView) titleView).getSymbol();
    if (symbol != null && symbol != mSymbol) {
      Log.i(IOUtils.TAG, "onPopupModified: update symbol");
      mSymbol = symbol;
      addFeature(mCurrentLocation);
    }
  }
  ……;
}

@Override
public void onPopupValidityChanged(boolean isValid) {
  Log.i(IOUtils.TAG, "onPopupValidityChanged");
  mModified = true;
  mValid = isValid;
}
PopupContainer popupContainer = ;

popupContainer.setPopupBackgroundColor(Color.WHITE); // popup background color
popupContainer.setPopupTextColor(Color.BLACK); // text color
popupContainer.setPopupSelectorColors(Color.BLUE, Color.RED, 
  Color.CYAN, Color.MAGENTA); // selector colors

           
           

Thanks.