I'm trying to load a FeatureLayer with Stored Credentials from ArcGIS Online to a Map using ArcGIS SDK Runtime for Android. This is the code:
private void loadFeatureLayerWithStoredCredentials(String publicUrl) {
ArcGISMap map = new ArcGISMap(Basemap.Type.STREETS, xCenter, yCenter, zoomLevel);
ServiceFeatureTable serviceFeatureTable = new ServiceFeatureTable(publicUrl);
serviceFeatureTable.addDoneLoadingListener(() -> serviceFeatureTableProcess(serviceFeatureTable));
FeatureLayer featureLayer = new FeatureLayer(serviceFeatureTable);
map.getOperationalLayers().add(featureLayer);
mapView.setMap(map);
}
Attending customer requirements about security and limitations of access, I have to add Limit Usage to the Feature Layer:
And I have to change the code to add Referer Header to the request:
private void loadFeatureLayerWithStoredCredentials(String urlPublico, String referer) {
ArcGISMap map = new ArcGISMap(Basemap.Type.STREETS, xCenter, yCenter, zoomLevel);
ServiceFeatureTable serviceFeatureTable = new ServiceFeatureTable(urlPublico);
serviceFeatureTable.addDoneLoadingListener(() -> serviceFeatureTableProcess(serviceFeatureTable));
RequestConfiguration request = new RequestConfiguration();
request.getHeaders().put("Referer", referer);
serviceFeatureTable.setRequestConfiguration(request);
FeatureLayer featureLayer = new FeatureLayer(serviceFeatureTable);
map.getOperationalLayers().add(featureLayer);
mapView.setMap(map);
}
Since then I began to get this error:
Error: com.esri.arcgisruntime.io.JsonEmbeddedException: You do not have permissions
to access this resource or perform this operation.
Can somebody help me?
Marcelo César Torres