Now to our code (Tested this on the phone not on emulator).
Add In Manifest.xml
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>In Main.java
LocationManager m_location_manager = (LocationManager) getSystemService(LOCATION_SERVICE); Location lm = m_location_manager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); Log.d("log",lm.toString());
The first line get our system service and the second line would get the last know location based on the network provider.
* Please take note that this assumes that it has a last known location, in order to know have location please see the function requestLocationUpdates.
LocationManager in developer.andriod.com
Jan 17, 2012 - Visual Update