I keep getting java.util.concurrent.ExecutionException: com.esri.arcgisruntime.ArcGISRuntimeException: Cannot call this method in this context for the tableQueryResult.get(); Any clue why?
Thanks in Advance.
private void queryFeaturesFromTable() {
ServiceFeatureTable table = new ServiceFeatureTable(
"https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails/FeatureServer/0");
table.loadAsync();
table.addDoneLoadingListener(() -> {
QueryParameters query = new QueryParameters();
query.setWhereClause("1=1");
query.setReturnGeometry(true);
ListenableFuture<FeatureQueryResult> tableQueryResult = table.queryFeaturesAsync(query);
tableQueryResult.addDoneListener(() -> {
try {
List<Graphic> graphics = new ArrayList<>();
FeatureQueryResult result = tableQueryResult.get();
result.forEach(feature -> {
graphics.add(new Graphic(feature.getGeometry()));
});
} catch (ExecutionException | InterruptedException e) {
System.out.println("Error querying Service Table: " + e);
}
});
});
}