I'm trying to get the longitude and latitude for android, here is my code:
LocationManager locationManager = (LocationManager)
this_activity.getSystemService(Context.LOCATION_SERVICE);
LocationListener locationListener = new MyLocationListener();
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER, 5000, 10, locationListener);
public class MyLocationListener implements LocationListener {
@Override
public void onLocationChanged(Location loc) {
longitude = Double.toString(loc.getLongitude());
latitude = Double.toString(loc.getLatitude());
}
@Override
public void onProviderDisabled(String provider) {}
@Override
public void onProviderEnabled(String provider) {}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {}
}
Manifest Permissions:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
I'm always getting 0.0s for longitude and latitude