Friday, May 15, 2009


While having problems on ACCESS_CHECKIN_PROPERTIES permission, i decided to journey to ACCESS_COARSE_LOCATION first. Some of you might ask what's the difference between ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION. ACCESS_COARSE_LOCATION is network based location access meaning the location is by your network, it could work with buildings or underground trains as long as you have access to your network while ACCESS_FINE_LOCATION is using gps thus your phone needs to be united with the sky (Correct me if im wrong here).

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>
LocationManager m_location_manager = (LocationManager) getSystemService(LOCATION_SERVICE);
Location lm = m_location_manager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

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.

Google Groups
LocationManager in|^%29android/location/LocationManager\.java$

Update History
   Jan 17, 2012 - Visual Update
Post a Comment