In the logs zeros

public class GpsLocation { private double latitude; private double longitude; public static final String TAG = "gps_debug_logs"; LocationListener locationListener = new LocationListener() { @Override public void onLocationChanged(Location location) { double latitude = location.getLatitude(); double longitude = location.getLongitude(); Log.d(TAG, "Latitude=" + location.getLatitude()); Log.d(TAG, "longitude=" + location.getLongitude()); } @Override public void onStatusChanged(String provider, int status, Bundle extras) { } @Override public void onProviderEnabled(String provider) { } @Override public void onProviderDisabled(String provider) { } }; public double getLatitude() { return latitude; } public double getLongitude() { return longitude; }} 

Permishn is

 <uses-permission `android:name="android.permission.LOCATION_HARDWARE"/>` <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
  • It would not be bad to show the call of this class - miha_dev

1 answer 1

Method call in main activity.

  GpsLocation gps = new GpsLocation(); Log.d(TAG, "Longitude= " + gps.getLongitude()); Log.d(TAG, "Latitude= " + gps.getLatitude());