-
Notifications
You must be signed in to change notification settings - Fork 0
search query with location
More information about request,response and other search street
To use Map query, you must add the
<uses-permission android:name="android.permission.INTERNET" />to your app's manifest. Without this, your app won't be able to connect to the network.
You can also handle a single type of event, if that's all you're interested in:
QuerySearch search = new QuerySearch(new QuerySearch.OnCallbackResult() {
@Override
public void onSuccess(JsonObject result) {
// processing data
}
@Override
public void onFailure(Throwable throwable) {
}
});or register listener
querySearch.registerOnSearchListener(new QuerySearch.OnCallbackResult() {
@Override
public void onSuccess(JsonObject result) {
// processing data
}
@Override
public void onFailure(Throwable throwable) {
}
});To get the values out of the QuerySearch, there’s a sendRequest method with the street parameter, example:
search.getLocationRequest(type, param);###type
- get_street - unique identifier of street
- get_object - Get company branches
- city - Get city by id
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 :
- Define object and add it to your requests.
QuerySearch querySearch; // Assume this exists.
querySearch.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 (querySearch != null) {
querySearch.onCancelRequest();
}
}