I am woefully green when it comes to using Android and the ESRI Android SDK (100.0.0). I apologize in advance for my greenhorn questions.
So I am looking to display a map service made of multiple layers in a simple Android app, I am current in my studio and gradle etc, as of last night (04/26/2017). I can handle the switch statements to change them but this issue I am running into is in actually getting them to display.
Here is the map service in question:
https://gis-server-02.usc.edu:6443/arcgis/rest/services/pjconner/fisheriesLandings/MapServer
I am currently building off of the Change Sublayer Visibility sample app hosted here on github:
arcgis-runtime-samples-android/change-sublayer-visibility at master · Esri/arcgis-runtime-samples-android · GitHub
The problem I am running into is that when I go to get/set the visibility on a specific sublayer, I get index out of range exceptions because I assume the GetSublayers method is failing. I am not sure why this is the case.
My current code is set up almost identical to the map initialization and layer set block in the example.
<SPAN class="comment token">// inflate MapView from layout</SPAN>
mMapView <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>MapView<SPAN class="punctuation token">)</SPAN> <SPAN class="token function">findViewById</SPAN><SPAN class="punctuation token">(</SPAN>R<SPAN class="punctuation token">.</SPAN>id<SPAN class="punctuation token">.</SPAN>mapView<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// create a map with the Basemap Type topographic</SPAN>
ArcGISMap map <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">ArcGISMap</SPAN><SPAN class="punctuation token">(</SPAN>Basemap<SPAN class="punctuation token">.</SPAN>Type<SPAN class="punctuation token">.</SPAN>TOPOGRAPHIC<SPAN class="punctuation token">,</SPAN> <SPAN class="number token">27.763528</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="operator token">-</SPAN><SPAN class="number token">82.543717</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">6</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// create a MapImageLayer with dynamically generated map images</SPAN>
mMapImageLayer <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">ArcGISMapImageLayer</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="token function">getResources</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">getString</SPAN><SPAN class="punctuation token">(</SPAN>R<SPAN class="punctuation token">.</SPAN>string<SPAN class="punctuation token">.</SPAN>landings_service_url<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
mMapImageLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">setOpacity</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="number token">0.5f</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// add world cities layers as map operational layer</SPAN>
map<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getOperationalLayers</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">add</SPAN><SPAN class="punctuation token">(</SPAN>mMapImageLayer<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// set the map to be displayed in this view</SPAN>
mMapView<SPAN class="punctuation token">.</SPAN><SPAN class="token function">setMap</SPAN><SPAN class="punctuation token">(</SPAN>map<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// get the layers from the map image layer</SPAN>
mLayers <SPAN class="operator token">=</SPAN> mMapImageLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getSublayers</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//This is the line where the error occurs</SPAN>
mLayers<SPAN class="punctuation token">.</SPAN><SPAN class="token function">get</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">setVisible</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="token boolean">true</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Despite the service displaying by default, it still doesn't show. So I figure I may have to manually set the visibility. As stated above. GetSubLayers seems to fail which leads to Null index exceptions when trying to force the layer visibility. Is this something wrong with my service, my code?
I would be truly grateful for any help!