I am creating an app related to location, so i need to get current latitude and longitude without having Internet Connection.
Please help me out. I am novice with Location Manager. Suggestion appreciated. Thanks Regards.
I am creating an app related to location, so i need to get current latitude and longitude without having Internet Connection.
Please help me out. I am novice with Location Manager. Suggestion appreciated. Thanks Regards.
There are Two ways to get the Location
1)Network provider
2)GPS Provider
for getting location through GPS Provider(without Internet) Use LocationManager.GPS_PROVIDER
as mentioned in the below Code
locationManager = (LocationManager) mContext.getSystemService(LOCATION_SERVICE);
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
MIN_TIME_BW_UPDATES,
MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
if (locationManager != null) {
location =locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location != null) {
latitude = location.getLatitude();
longitude = location.getLongitude();
}
}
and to know about the GPS status, whether enabled or not
boolean isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
and for Removing Updated
if(locationManager != null){locationManager.removeUpdates(this);