Hi.
I need to migrate an Android application developed with the ESRI SDK 10.2.8 to the newest SDK: 100.6.
My first big obstacle is migrating all the queries. Currently, they are done with the object QueryTask (which doesn't exist any longer). With it, I get the response from the server, I send the data with a return to the next step.
Now, it seems that all queries are asynchronous, so the data that is returned is always empty. How can I get a synchronous behaviour with the new SDK? I'm totally stuck.
ArrayList<Community> communities = new ArrayList<Community>();
QueryParameters query = new QueryParameters();
StringBuilder whereStrBuilder = new StringBuilder();
whereStrBuilder.append("display_order > 0");
query.setWhereClause(whereStrBuilder.toString());
OrderBy order = new OrderBy("display_order", SortOrder.ASCENDING);
query.getOrderByFields().add(order);
query.setReturnGeometry(false);
final ListenableFuture<FeatureQueryResult> future = Layer.SERVICE_COMMUNITY.queryFeaturesAsync(query, ServiceFeatureTable.QueryFeatureFields.LOAD_ALL);
future.addDoneListener(new Runnable() {
@Override
public void run() {
try {
FeatureQueryResult result = future.get();
Iterator<Feature> resultIterator = result.iterator();
while (resultIterator.hasNext()) {
Feature feature = resultIterator.next();
communities.add(featureToCommunity(feature));
}
} catch (Exception e) {
}
}
});
return communities;
communities is always empry, because it is returned before the addDoneListener is triggered. Is there a way of making the process wait until the query has finished so the proper list of communities is returned?
Thanks for any help provided!