How to get click event of the marker text

I am displaying google map api v2 in my app. I have set some markers in the map. I have also set title and snippet on the markers which are shown when you click the marker.

Now I want to call a new activity when clicked on the marker's title and not on marker itself.


is called only on the click of the marker.

But I dont want to do that. I want the marker to show the title and snippet on the click of the marker but I want to call new activity on the click of the title.

Any idea how we do that?



To achieve this you need to implement setOnInfoWindowClickListener in your getInfoContents method so that a click on your infoContents window will wake the listener to do what you want, you do it like so:

   map.setInfoWindowAdapter(new InfoWindowAdapter() {

            // Use default InfoWindow frame
            public View getInfoWindow(Marker args) {
                return null;

            // Defines the contents of the InfoWindow
            public View getInfoContents(Marker args) {

                // Getting view from the layout file info_window_layout
                View v = getLayoutInflater().inflate(R.layout.info_window_layout, null);

                // Getting the position from the marker
                clickMarkerLatLng = args.getPosition();

                TextView title = (TextView) v.findViewById(;

                map.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {          
                    public void onInfoWindowClick(Marker marker) 
                        if (SGTasksListAppObj.getInstance().currentUserLocation!=null)
                            if (String.valueOf(SGTasksListAppObj.getInstance().currentUserLocation.getLatitude()).substring(0, 8).contains(String.valueOf(clickMarkerLatLng.latitude).substring(0, 8)) &&
                                    String.valueOf(SGTasksListAppObj.getInstance().currentUserLocation.getLongitude()).substring(0, 8).contains(String.valueOf(clickMarkerLatLng.longitude).substring(0, 8)))
                                Toast.makeText(getApplicationContext(), "This your current location, navigation is not needed.",  Toast.LENGTH_SHORT).show();
                                FlurryAgent.onEvent("Start navigation window was clicked from daily map");
                                tasksRepository = SGTasksListAppObj.getInstance().tasksRepository.getTasksRepository();
                                for (Task tmptask : tasksRepository)
                                    String tempTaskLat = String.valueOf(tmptask.getLatitude());
                                    String tempTaskLng = String.valueOf(tmptask.getLongtitude());

                                    Log.d(TAG, String.valueOf(tmptask.getLatitude())+","+String.valueOf(clickMarkerLatLng.latitude).substring(0, 8));

                                    if (tempTaskLat.contains(String.valueOf(clickMarkerLatLng.latitude).substring(0, 8)) && tempTaskLng.contains(String.valueOf(clickMarkerLatLng.longitude).substring(0, 8)))
                                        task = tmptask;

                                Intent intent = new Intent(getApplicationContext() ,RoadDirectionsActivity.class);
                                intent.putExtra(TasksListActivity.KEY_ID, task.getId());

                            Toast.makeText(getApplicationContext(), "Your current location could not be found,\nNavigation is not possible.",  Toast.LENGTH_SHORT).show();

                // Returning the view containing InfoWindow contents
                return v;


To set a title on a marker:


To set a click listener on title:

googleMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {

    public void onInfoWindowClick(Marker arg0) {
        // TODO Auto-generated method stub


GoogleMap mGoogleMap;  
mGoogleMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {

                    public void onInfoWindowClick(Marker arg0) {
                        Intent intent = new Intent(getBaseContext(), Activity.class);
                        String reference = mMarkerPlaceLink.get(arg0.getId());
                        intent.putExtra("reference", reference);

                        // Starting the  Activity
                        Log.d("mGoogleMap1", "Activity_Calling");

 * adding individual markers, displaying text on on marker click on a
 * bubble, action of on marker bubble click
private final void addLocationsToMap() {
    int i = 0;
    for (Stores store : storeList) {
        LatLng l = new LatLng(store.getLatitude(), store.getLongtitude());

        MarkerOptions marker = new MarkerOptions()
                .snippet("" + i)

    googleMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {

        public void onInfoWindowClick(Marker marker) {

            try {
                Stores store = storeList.get(Integer.parseInt(marker

                // set details

                // setting test value to phone number
                tempString = store.getPhone();
                SpannableString spanString = new SpannableString(tempString);
                spanString.setSpan(new UnderlineSpan(), 0,
                        spanString.length(), 0);

                // setting test value to email
                tempStringemail = store.getEmail();

                SpannableString spanString1 = new SpannableString(tempStringemail);
                spanString1.setSpan(new UnderlineSpan(), 0, spanString1.length(), 0);

                storeLat = store.getLatitude();
                storelng = store.getLongtitude();

            } catch (ArrayIndexOutOfBoundsException e) {
                Log.e("ArrayIndexOutOfBoundsException", " Occured");



Need Your Help

Javascript eval() Exception - line number

javascript exception eval node.js v8

In JavaScript I have a var str = ".a long string that contains many lines..."

How to watch logs in real time via Terminal?

apache-2.2 php logging lamp terminal

This is a basic question - in the movie "The Social Network" there are several scenes when the young Facebook staff is watching the PHP/Apache server logs on in their TERMINAL in real time.