In this article, we will develop an Android application that can search Google Places API using SearchView widget and show the results in Google Maps Android API V2. In this application the searchview widget is placed in action bar.

We know that, the SearchView widget is available only since Android API level 11. So will use ActionBarSherlock library for the backward compatibility.

Major files used in this application are listed below :

MainActivity.java : The search action is placed in the action bar of the MainActivity.

searchable.xml : This is the configuration file for search dialog which defines content provider and suggestion properties.

In this application, we are using ActionBarSherlock library for the backward compatibility support of Android versions. Since ActionBarSherlock library already contains the Android Support library, we have to delete the Android Support Library (android-support-v4.jar) from this project, if it is added automatically by Eclipse IDE.

The modified code and your original code look almost the same. The only difference is my modified code using Intent.ACTION_SEARCH.equals(intent.getAction()and Intent.ACTION_VIEW.equals(intent.getAction()as the if-else condition, whereas your original code using intent.getAction().equals(Intent.ACTION_SEARCH)and intent.getAction().equals(Intent.ACTION_VIEW). I have referenced http://developer.android.com/training/search/setup.html and modified my handleIntent() accordingly. I have no idea why your code works well only when the searchable activity is a launcher activity, but it doesn’t work when I try to intent to this activity from another activity.

Hi.. thankx for ur post. but whenever i tried to search the following error appears on CatLog and no searched is done. Here is my error:SpannableStringBuilder SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length what can I do to correct this error? I’m running in mobile device not in emulator.

this code is perfectly running. however there is one problem I am facing. Every time I click on a query that will place marker on map, a new activity is created by LoaderManager, I want to map every query in a single activity.

Good afternoon. How can I pause for 1 second delay calling query data from Google Place Api? It is necessary that the user has finished typing a word, without sending a request for each character entered. The problem is that it is necessary to wait until the user has finished typing a word. Otherwise cases are multiple access Place API that can deplete the query limit

Good afternoon. How can I pause for 1 second delay calling query data from Google Place Api? It is necessary that the user has finished typing a word, without sending a request for each character entered. The problem is that it is necessary to wait until the user has finished typing a word. Otherwise cases are multiple access Place API that can deplete the query limit

Generaly I have HUGE problems with the fact that I need to use Sherlock. I have drawer done and I can’t use sherlock library. In that case my SearchView is simply nullpointer. SearchView from appcompatv7 is not compatabile. Any hints how to overcome this obstacle?