The problem I am facing is that it always returns 0.0
for latitude and longitude.
and addresses is null. I have turned on the GPS settings in the phone and set all the permissions
if (gps.isGPSEnabled) {
progressDialog.setMessage("Loading...");
progressDialog.show();
double latitude = gps.getLatitude();
double longitude = gps.getLongitude(); // returns longitude
Geocoder gcd = new Geocoder(context);
List<Address> addresses = null;
try {
addresses = gcd.getFromLocation(latitude,longitude,1);
} catch (IOException e) {
e.printStackTrace();
}
if (addresses.size() > 0) {
service.refreshWeather(addresses.get(0).getLocality().toString());
} else {
}
} else {
gps.showSettingsAlert();
}