| Private Class Asyncquerytask extends asynctask<string, Void, featureset> { protected void OnPreExecute () { Show a progress bar when no results are queried progress = ProgressDialog. Show (Attributequery. This, "", "Wait....query task is executing"); } protected FeatureSet doinbackground (String ... queryparams) { if (Queryparams = = Null | | queryparams.length <= 1) return null; Query criteria and URL parameters String URL = queryparams[0]; Query the required parameter classes Query query = new query (); String whereclause = queryparams[1]; spatialreference sr = spatialreference. Create (102100); Query.setgeometry (new Envelope (-20147112.9593773, 557305.257274575, -6569564.7196889, 11753184.6153385));//Set Query space scope Query.setoutspatialreference (SR);//Set the coordinate system of the query output Query.setreturngeometry (true);//whether to return spatial information Query.setwhere (whereclause);//where conditions Querytask qtask = new querytask (URL);//Query Task class FeatureSet fs = null; Try { FS = Qtask.execute (query);//execute query, return query result } catch (Exception e) { TODO auto-generated Catch block E.printstacktrace (); return FS; } return FS; } protected void OnPostExecute (featureset result) { String message = "No result comes back"; if (Result! = null) { graphic[] Grs = Result.getgraphics (); if (Grs.length > 0) { Gl.addgraphics (GRS); Add query results to a layer Message = (Grs.length = = 1?) "1 result has": Integer . toString (grs.length) + "Results has") + "Come Back"; } } Progress.dismiss ();//Stop progress bar Toast toast = toast. Maketext (Attributequery. This, message, Toast. Length_long); Toast.show (); Querybt.settext ("Clear graphics"); Blquery = false; } } |