After you receive mLocListener - set the criteria as shown below
String mlocProvider;
Criteria hdCrit = new Criteria();
hdCrit.setAccuracy(Criteria.ACCURACY_COARSE);
mlocProvider = mlocManager.getBestProvider(hdCrit, true);
and then use getLastKnownLocation
tv.append("\n\nLocations (starting with last known):");
Location currentLocation = mlocManager.getLastKnownLocation(mlocProvider);
Make sure you have it in your manifest
uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"
uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"
If you use the emulator - in DDMS Perspective, find the location controls on the "Emulator Management" tab. Then use the “Manual” tab to set the longitude and latitude, and click “Submit” - do this when your program is running, you see the onLocationchanged call. It is a good idea to enter onLocationChanged.
BTW, the parameters in requestLocationUpdates are set to "... 0,0 ..." - it will drain your battery - I saw the phone go out within 6 - 8 hours - change it to "... 30000, 100 ... "is the first parameter in milliseconds and the other is in meters.
source share