Unable to use Token and Referer to query features table in android ArcGIS SDK

386
0
11-11-2018 10:59 PM
manojkumar9
New Contributor

Below is the code I'm using for setting user credentials on ServiceFeatureTable.

credential = UserCredential.createFromToken(gisToken, referer);

ServiceFeatureTable featureTablePolygons = new ServiceFeatureTable(polygonUrl);
featureTablePolygons.setCredential(credential);

final ListenableFuture<FeatureQueryResult> queryResultPolygons = featureTablePolygons.queryFeaturesAsync(query);
queryResultPolygons.addDoneListener(() -> {
try {
FeatureCollection featureCollection = new FeatureCollection();
FeatureQueryResult result = queryResultPolygons.get();
FeatureCollectionTable featureCollectionTable = new FeatureCollectionTable(result);
featureCollection.getTables().add(featureCollectionTable);
FeatureCollectionLayer featureCollectionLayer = new FeatureCollectionLayer(featureCollection);
mMapView.getMap().getOperationalLayers().add(featureCollectionLayer);

if (result.iterator().hasNext()) {
Feature feature = result.iterator().next();
Envelope envelope = feature.getGeometry().getExtent();
mMapView.setViewpointGeometryAsync(envelope);
} else {
// Toast.makeText(mContext, "No polygons found for " + queryString, Toast.LENGTH_SHORT).show();
}
} catch (InterruptedException | ExecutionException e) {
Log.e(TAG, "Error in FeatureQueryResult: " + e.getMessage());
}
});

But this is not working. If I'm using AuthenticationManager then it's working fine but I don't want to use username and password in my code.

0 Kudos
0 Replies