I am using the following library to do this. https://code.google.com/p/little-fluffy-location-library/
It is easy to use but it doesn't give much flexibility. You cannot change the update frequency on-the-fly for instance. But its source is available, you can convert it.