Get Current Location using GPS/Network Provider
Hello to all, Today I teach you that how can we get current location. In android's new SDK tools, LocationManager class does not give any network provider's status. It always gives null value. Still it works in some of the android devices rarely. So that's why I include code for both network provider and gps provider for getting current location. Create one service class name LocationFinder and implements it LocationListener . All the code which is related to Location, is doing in that service class and from MainActivity , call its method through its instance in onResume() method. The reason you know, why its called in onResume(), because when you enable GPS and come back in activity, then its again check Location's status. In the code, if GPS not enable, I show settings alert pop-up, to go settings menu. When you enable GPS, you will get current location after 2-3 seconds. If not, come again to activity and surely get location. Make sure, must add persmi...
Comments
Post a Comment