Skip to content

Search street by query string

Mapmd edited this page May 13, 2019 · 6 revisions

More information about request,response and other search street

   QuerySearch search = new QuerySearch(new QuerySearch.OnCallbackResult() {
            @Override
            public void onSuccess(JsonObject result) {
             // processing data
            }

            @Override
            public void onFailure(Throwable throwable) {

            }
        });

or register listener

search.registerOnSearchListener(new QuerySearch.OnCallbackResult() {
            @Override
            public void onSuccess(JsonObject result) {
             // processing data
            }

            @Override
            public void onFailure(Throwable throwable) {

            }
        });

Call function

search.sendRequest("calea orheiului");

Cancel a request:

To cancel a request, call onCancelRequest() on your Request object. Once cancelled your response handler will never be called. What this means in practice is that you can cancel all of your pending requests in your activity's onStop() method and you don't have to litter your response handlers with checks for getActivity() == null, whether onSaveInstanceState() has been called already, or other defensive boilerplate.

To take advantage of this behavior, you would typically have to track all in-flight requests in order to be able to cancel them at the appropriate time. There is an easier way: you can associate a tag object with each request. You can then use this tag to provide a scope of requests to cancel. For example, you can tag all of your requests with the Activity they are being made on behalf of, and call querySearch.onCancelRequest from onStop(). Here is an example :

  1. Define object and add it to your requests.
QuerySearch search;  // Assume this exists.

search.registerOnSearchListener(new QuerySearch.OnCallbackResult() {
            @Override
            public void onSuccess(JsonObject result) {
             // processing data
            }

            @Override
            public void onFailure(Throwable throwable) {

            }
        });

2.In your activity's onStop() method, cancel all requests that have this object.

@Override
protected void onStop () {
    super.onStop();
    if (requestQueue != null) {
        requestQueue.cancelAll(TAG);
    }
}

Clone this wiki locally