This is the official google tutorial to obtain the user location. It could be based on the GPS or WiFi. Pretty interesting.
There are some guides that shows examples of how to code. They are:
1. About Android - Find Current Location in Android - GPS Sample
It is a very basic example that just works. (Tested)
2. Devx.com : You Are Here: Using GPS and Google Maps in Android
It shows you more complicated example. (Not tested)