how to fix error “Cannot call this method in this context when use query.setMaxFeatures(20);

278
0
07-15-2019 09:20 AM
lasinh
by
New Contributor III

if i use "query.setMaxFeatures(20);" my code show error Cannot call this method in this context

if i not use "query.setMaxFeatures(20);" working.

how to select top record by use setMaxFeatures method

final QueryParameters query = new QueryParameters(); // 
query.setWhereClause("upper(name) LIKE '%" + strSearch.toUpperCase() + "%'");
query.setReturnGeometry(false);
query.setMaxFeatures(20);

final ListenableFuture<FeatureQueryResult> future = ServiceFeature.queryFeaturesAsync(query, ServiceFeatureTable.QueryFeatureFields.LOAD_ALL);
    public void run() {
        try {
            final FeatureQueryResult result = future.get(); 
            Iterator<Feature> iterator = result.iterator();
            int count = 0;
            ...
            ...

0 Kudos
0 Replies