ArcGIS Feature Layer with Callouts not working properly

Discussion created by JFA0427 on Jul 12, 2013
Latest reply on Jul 12, 2013 by JFA0427
I have one map document with the same layer added three times, each layer has a different color symbol. I published the map as a map service on our server. In my app I call each layer from the map service separately, each as ArcGIS Feature Layers.

When I open the map all three ArcGIS Feature layers appear.

Next, I have a callout set-up in my app. When you click on a point from one of the feature layers the callout is suppose to appear for each of the three feature layers, BUT the callout only appears for one of them.

The reason I set-up the app this way is because I initially had one ArcGIS feature layer with a callout and everything worked fine. Then, I needed to be able to turn different colored dots off, so thats when I went back and added the same layer three times with different colored dots for each in my published map document, then I called those layers separately in my app, now only one of the layers callouts work.

Only callouts for flayer are working.

Java Code:
public class Mapscreen extends Activity {

 public MapView map;  
 //Callout Variables
 private int m_calloutStyle;
 private Callout m_callout;
 private ViewGroup calloutContent;
 private Graphic m_identifiedGraphic;
 ArcGISFeatureLayer fLayer;
 ArcGISFeatureLayer fLayer1;
 ArcGISFeatureLayer fLayer2;
 ImageView CallOutClose;
 //Basemap Variables.
 ArcGISTiledMapServiceLayer basemapImagery;
 ArcGISTiledMapServiceLayer basemapTopo;

 /** Called when the activity is first created. */
 public void onCreate(Bundle savedInstanceState) {
  // Initial activity content view. (START)

  // Retrieve the map layout and initial extent from mapscreen XML layout.
  map = (MapView) findViewById(R.id.map);   
  // Get basemaps
  basemapTopo = new ArcGISTiledMapServiceLayer(this.getResources().getString(R.string.WORLD_TOPO_MAP));
  // Add basemaps
  // Get feature layer = Blue = No
  String URL = "http://...../MapServer/2";
  final ArcGISFeatureLayer fLayer2 = new ArcGISFeatureLayer(URL, MODE.ONDEMAND);
  // Get feature layer = Yellow = Unknown
  String URL1 = "http://...../MapServer/1";
  final ArcGISFeatureLayer fLayer1 = new ArcGISFeatureLayer(URL1, MODE.ONDEMAND);
  // Get feature layer = Green = Yes
  String URL2 = "http://...../MapServer/0";
  final ArcGISFeatureLayer fLayer = new ArcGISFeatureLayer(URL2, MODE.ONDEMAND);
  // Add feature layers

  // This puts the ERSI logo on the bottom left corner of the screen once the map screen appears. This is mandatory by
  LayoutInflater inflater = getLayoutInflater();
  // Get the MapView's callout from xml->identify_calloutstyle.xml
  m_calloutStyle = R.xml.facility_calloutstyle;
  // Get the layout for the Callout from layout->identify_callout_content.xml
  calloutContent = (ViewGroup) inflater.inflate(R.layout.facility_callout_content, null);  
  m_callout = map.getCallout();  

                //Callout Part - 1
  map.setOnSingleTapListener(new OnSingleTapListener() {

   private static final long serialVersionUID = 1L;

   public void onSingleTap(float x, float y) {

    if (m_isMapLoaded) {
     // If map is initialized and Single tap is registered on screen identify the location selected
     identifyLocation(x, y);
// Initial activity content view. (END)

//Callout Part - 2
  * Takes in the screen location of the point to identify the feature on map.
  * @param x
  *            x co-ordinate of point
  * @param y
  *            y co-ordinate of point
 private void identifyLocation(float x, float y) {

  // Hide the callout, if the callout from previous tap is still showing on map
  if (m_callout.isShowing()) {

  // Find out if the user tapped on a feature
  SearchForFeature(x, y);

  // If the user tapped on a feature, then display information regarding the feature in the callout
  if (m_identifiedGraphic != null) {
   Point mapPoint = map.toMapPoint(x, y);
   // Show Callout
   ShowCallout(m_callout, m_identifiedGraphic, mapPoint);
   //Close button for the callout is initiated here.
   ImageView CallOutClose = (ImageView) findViewById(R.id.callout_close_button);
   CallOutClose.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
 //Callout Part - 3
  * Sets the value of m_identifiedGraphic to the Graphic present on the
  * location of screen tap
  * @param x
  *            x co-ordinate of point
  * @param y
  *            y co-ordinate of point
 private void SearchForFeature(float x, float y) {

  Point mapPoint = map.toMapPoint(x, y);

  if (mapPoint != null) {

   for (Layer layer : map.getLayers()) {
    if (layer == null)

    if (layer instanceof ArcGISFeatureLayer) {
     ArcGISFeatureLayer fLayer = (ArcGISFeatureLayer) layer;
     // Get the Graphic at location x,y
     m_identifiedGraphic = GetFeature(fLayer, x, y);
    } else
 //Callout Part - 4
  * Returns the Graphic present the location of screen tap
  * @param fLayer
  * @param x
  *            x co-ordinate of point
  * @param y
  *            y co-ordinate of point
  * @return Graphic at location x,y
 private Graphic GetFeature(ArcGISFeatureLayer fLayer, float x, float y) {

  // Get the graphics near the Point.
  int[] ids = fLayer.getGraphicIDs(x, y, 10, 1);
  if (ids == null || ids.length == 0) {
   return null;
  Graphic g = fLayer.getGraphic(ids[0]);
  return g;
 //Callout Part - 5
  * Shows the Attribute values for the Graphic in the Callout
  * @param calloutView
  * @param graphic
  * @param mapPoint
 private void ShowCallout(Callout calloutView, Graphic graphic, Point mapPoint) {

  // Get the values of attributes for the Graphic
  String Name = (String) graphic.getAttributeValue("Name");
  String Phone = (String) graphic.getAttributeValue("Phone"); 

  // Set callout properties

  TextView calloutTextLine0 = (TextView) findViewById(R.id.callout_content_textview0);     
  calloutTextLine0.setText("Name:" + " " + Name);
  TextView calloutTextLine1 = (TextView) findViewById(R.id.callout_content_textview1); 
  calloutTextLine1.setText("Phone:" + " " + Phone);