Show a Private Layer

587
4
04-06-2017 01:09 AM
AntonioFiume
New Contributor III

Hi everybody,

i'm using ArcGIS SDK 100.0.0 for Android.

I found some guide to access to private layer but only with the old version.

I need to show a private layer using the last version 100.0.0.

This is my simple code:

 private static final String CVWLayersTEST = "https://XXXX/arcgis/rest/services/XXX/XXX/FeatureServer/0";
 [...]
 mMapView = (MapView) findViewById(R.id.mapView);
 ArcGISMap map = new ArcGISMap(Basemap.Type.TOPOGRAPHIC, 34.056295, -117.195800, 1);


 mServiceFeatureTable = new ServiceFeatureTable(CVWLayersTEST);
 mStreetsLayer = new FeatureLayer(mServiceFeatureTable);

 map.getOperationalLayers().add(mStreetsLayer);

 mMapView.setMap(map);

[...]

Ih the layer is public the application shows the layer.

If the application is private the system doesn't show nothing because need a credential.

How ca i pass the credential in my code?

Some example found on forum use different classes used in the Old version about SDK.

Thanks in Advance.

Antonio

0 Kudos
4 Replies
AntonioFiume
New Contributor III

Seem the equivalent for the new version should be the following:

ArcGISMapImageLayer mapImageLayer = new ArcGISMapImageLayer(MALSATLayers);
mapImageLayer.setCredential(mycredentials);
0 Kudos
AntonioFiume
New Contributor III

Sorry guys but is not clear.

I tried with the only solution that i discovered that use the credentials, so the ArcGISMapImageLayer:

ArcGISMapImageLayer mapImageLayer = new ArcGISMapImageLayer("https://XXXX/arcgis/rest/services/XXX/XXX/MapServer");
mapImageLayer.setCredential(mycredentials);

map.getOperationalLayers().add(mapImageLayer);

but the system shows onle the first layer.

The MapServer haves 10 layers

0 Kudos
AntonioFiume
New Contributor III

no help?

0 Kudos
ShellyGill1
Esri Contributor

Hi Antonio - you might want to look at using the AuthenticationManager - this can take care of authenticating at runtime - it's pretty simple to set up and described here - Access the ArcGIS platform: Authentication Manager—ArcGIS Runtime SDK for Android | ArcGIS for Devel... .

0 Kudos