AutoCompleteView – Synchronous server call with Filter

In order to implement synchronous server calling within filter, autocomplete textview is being used. Web service is hit with each character typed in Autocomplete list. For having data dynamically in the list, we can make customized adapter. I have implemented it by making this adapter to implement filterable interface.

For getting data from server, two approaches can be used:

1) Using volley library:

Volley request can be made inside the performFiltering() function which gets callback after each character is typed. But the problem in this approach is due to asynchronous request , different thread is started and before getting any result, the execution of performFiltering() function stops. So we don’t receive result from server and before that publishResults() function is called to display the result to UI.

2) Using Async Task:


In WebServiceManager :

Being synchronous call, call is made to server and the results are obtained before performFiltering() function stops executing. So the autocomplete list is obtained.

Leave a Reply