0

I need to get my mobile current location using GPS programmatically. How do I do that?

MBMJ
  • 5,323
  • 8
  • 32
  • 51
  • 1
    possible duplicate of [How do I get the current GPS location programmatically in Android?](http://stackoverflow.com/questions/1513485/how-do-i-get-the-current-gps-location-programmatically-in-android) – npinti May 23 '12 at 08:10

2 Answers2

3

There is a complete explanation of how obtaining the current position in the training pages of the official android documentation.

ol_v_er
  • 27,094
  • 6
  • 48
  • 61
2
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, gpsListener);

LocationListener gpsListener = new LocationListener() {
        @Override
        public void onLocationChanged(Location location) {
            //          

        }

        @Override
        public void onProviderDisabled(String provider) {
        }

        @Override
        public void onProviderEnabled(String provider) {
        }

        @Override
        public void onStatusChanged(String provider, int status, Bundle extras) {
        }
    };
Rasel
  • 15,499
  • 6
  • 40
  • 50