Error while Querying the feature layer

359
1
08-31-2019 11:28 PM
AsifIsmail
New Contributor III

Hi all,

i use arcgis android 100.5 to load and query the layer.

but often i get this error :

java.util.concurrent.ExecutionException: com.esri.arcgisruntime.ArcGISRuntimeException: Cannot call this method in this context

please help,this is my code 

public static void queryLayer(
ServiceFeatureTable serviceFeatureTable, MapActivity.LayerQueriedListener listener) {
serviceFeatureTable.loadAsync();
serviceFeatureTable.setCredential(Utilities.getUserCredentials());
serviceFeatureTable.addDoneLoadingListener(
() -> {
QueryParameters queryParameters = new QueryParameters();
ListenableFuture<FeatureQueryResult> future =
serviceFeatureTable.queryFeaturesAsync(
queryParameters);
future.addDoneListener(
() -> {
try {
FeatureQueryResult result = future.get();
Iterator<Feature> featureIterator = result.iterator();
if (featureIterator.hasNext()) {
Feature feature = featureIterator.next();
listener.onLayerQueryCompleted(feature.getGeometry());
}
} catch (ExecutionException | InterruptedException e) {
System.out.println("Error querying service table :" + e.getCause());
}
});
});
}

the issue is so annoying,pls address 

0 Kudos
1 Reply
AsifIsmail
New Contributor III

Hey People at Esri,This issue is so intimidating ... kindly please adress the issue 

0 Kudos