Q:

Add identification to marker on google maps v2 api for android

Well, every marker on my application will represent a user, so I need to identify that user when I click the info window to get its data from the Internet, and I can't make it identify them by name for obvious reasons. Is it possible to add an extra attribute to a marker object? thanks!

A:

You could make a HashMap<Marker, User>
check this tutorial:
http://bon-app-etit.blogspot.be/2012/12/add-informationobject-to-marker-in.html

A:

Is it possible to add an extra attribute to a marker object?

No. Marker is final. Also, the Marker objects you create vanish quickly, as they are only used for some IPC over to the Google Play Services app. The Marker object you get in your OnInfoWindowClickListener appears to be a reconstituted copy.

I have a subtitle in the snippet field so that's not an option.

Sure it is. Store the subtitle someplace else, and put your key to your user in the subtitle. When you render the InfoWindow from your InfoWindowAdapter, pull in the subtitle.

A:

I dont think it is a good idea to keep strong references to markers via a map. Since you anyway use your custom window adapter to render contents, you could either "abuse" the snippet() or title() on the MarkerOptions to store your information. They are both strings, so depended on the information to store you would slightly use more memory, on the other side you'd be safe from memory leaks by holding strong references to markers.
also, you would go compatible to the way how Maps manages it persistency during stops and resumes.

