I have created a small application with step by step description to get current location's GPS coordinates.

Complete example source code is in Get Current Location coordinates , City name - in Android.


See how it works:

  • All we need to do is add this permission in the manifest file:

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    
  • And create a LocationManager instance like this:

    LocationManager locationManager = (LocationManager)
    getSystemService(Context.LOCATION_SERVICE);
    
  • Check if GPS is enabled or not.

  • And then implement LocationListener and get coordinates:

    LocationListener locationListener = new MyLocationListener();
    locationManager.requestLocationUpdates(
    LocationManager.GPS_PROVIDER, 5000, 10, locationListener);
    
  • Here is the sample code to do so


/*---------- Listener class to get coordinates ------------- */
private class MyLocationListener implements LocationListener {

    @Override
    public void onLocationChanged(Location loc) {
        editLocation.setText("");
        pb.setVisibility(View.INVISIBLE);
        Toast.makeText(
                getBaseContext(),
                "Location changed: Lat: " + loc.getLatitude() + " Lng: "
                    + loc.getLongitude(), Toast.LENGTH_SHORT).show();
        String longitude = "Longitude: " + loc.getLongitude();
        Log.v(TAG, longitude);
        String latitude = "Latitude: " + loc.getLatitude();
        Log.v(TAG, latitude);

        /*------- To get city name from coordinates -------- */
        String cityName = null;
        Geocoder gcd = new Geocoder(getBaseContext(), Locale.getDefault());
        List<Address> addresses;
        try {
            addresses = gcd.getFromLocation(loc.getLatitude(),
                    loc.getLongitude(), 1);
            if (addresses.size() > 0) {
                System.out.println(addresses.get(0).getLocality());
                cityName = addresses.get(0).getLocality();
            }
        }
        catch (IOException e) {
            e.printStackTrace();
        }
        String s = longitude + "\n" + latitude + "\n\nMy Current City is: "
            + cityName;
        editLocation.setText(s);
    }

    @Override
    public void onProviderDisabled(String provider) {}

    @Override
    public void onProviderEnabled(String provider) {}

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {}
}

Answer from swiftBoy on Stack Overflow
🌐
Android Developers
developer.android.com › core areas › sensors and location › get the last known location
Get the last known location | Sensors and location | Android Developers
The getLastLocation() method returns a Task that you can use to get a Location object with the latitude and longitude coordinates of a geographic location.
🌐
Wikihow
wikihow.com › computers and electronics › telephones › smartphones › android › get gps coordinates on android: google maps guide
Get GPS Coordinates on Android: Google Maps Guide
December 11, 2025 - Enter another location and tap and hold the red marker to see that location's GPS coordinates. ... Make sure your Android's GPS is turned on.
People also ask

Can I used Android Device Manager to find the GPS coordinates of my phone?

Absolutely! And, this is perfect if you've lost your phone in a body of water with low visibility, or somewhere in the wilderness where there isn't a street you can reference.

When you open the Android Device Manager on a web browser, click on the green icon indicating the location of your phone. A new window will open with Google Maps including the GPS coordinates of your missing phone.

From this webpage, you can share the location or get directions. Just bear in mind, this will only work if your phone is on, your Google account has permission to access your location, and it's getting some sort of internet signal.

🌐
alphr.com
alphr.com › home › how to find your gps coordinates on an android device
How To Find Your GPS Coordinates on an Android Device
How accurate is my GPS coordinates on my phone?

Although there is some debate on this, your coordinates should be fairly accurate assuming your Magnetometer is working properly. This is something you may need to calibrate periodically to ensure that it is giving you the most accurate results.

If you're unsure of the accuracy and traveling somewhere it's imperative that you have your exact GPS coordinates it is recommended that you carry a device built for this rather than relying on a smartphone.

🌐
alphr.com
alphr.com › home › how to find your gps coordinates on an android device
How To Find Your GPS Coordinates on an Android Device
Top answer
1 of 16
456

I have created a small application with step by step description to get current location's GPS coordinates.

Complete example source code is in Get Current Location coordinates , City name - in Android.


See how it works:

  • All we need to do is add this permission in the manifest file:

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    
  • And create a LocationManager instance like this:

    LocationManager locationManager = (LocationManager)
    getSystemService(Context.LOCATION_SERVICE);
    
  • Check if GPS is enabled or not.

  • And then implement LocationListener and get coordinates:

    LocationListener locationListener = new MyLocationListener();
    locationManager.requestLocationUpdates(
    LocationManager.GPS_PROVIDER, 5000, 10, locationListener);
    
  • Here is the sample code to do so


/*---------- Listener class to get coordinates ------------- */
private class MyLocationListener implements LocationListener {

    @Override
    public void onLocationChanged(Location loc) {
        editLocation.setText("");
        pb.setVisibility(View.INVISIBLE);
        Toast.makeText(
                getBaseContext(),
                "Location changed: Lat: " + loc.getLatitude() + " Lng: "
                    + loc.getLongitude(), Toast.LENGTH_SHORT).show();
        String longitude = "Longitude: " + loc.getLongitude();
        Log.v(TAG, longitude);
        String latitude = "Latitude: " + loc.getLatitude();
        Log.v(TAG, latitude);

        /*------- To get city name from coordinates -------- */
        String cityName = null;
        Geocoder gcd = new Geocoder(getBaseContext(), Locale.getDefault());
        List<Address> addresses;
        try {
            addresses = gcd.getFromLocation(loc.getLatitude(),
                    loc.getLongitude(), 1);
            if (addresses.size() > 0) {
                System.out.println(addresses.get(0).getLocality());
                cityName = addresses.get(0).getLocality();
            }
        }
        catch (IOException e) {
            e.printStackTrace();
        }
        String s = longitude + "\n" + latitude + "\n\nMy Current City is: "
            + cityName;
        editLocation.setText(s);
    }

    @Override
    public void onProviderDisabled(String provider) {}

    @Override
    public void onProviderEnabled(String provider) {}

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {}
}

2 of 16
47

There are already many answers there but I want to show latest way to get location using Google API, so new programmers can use new method:

I have written detailed tutorial on current location in android at my blog demonuts.com You can also find full source code developed with android studio.

First of all, put this in gradle file

 compile 'com.google.android.gms:play-services:9.0.2'

then implement necessary interfaces

public class MainActivity  extends BaseActivitiy implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, com.google.android.gms.location.LocationListener

declare instances

  private GoogleApiClient mGoogleApiClient;
  private Location mLocation;
  private LocationManager locationManager;
  private LocationRequest mLocationRequest;

put this in onCreate()

 mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(LocationServices.API)
                .build();
        locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

At last, override necessary methods

 @Override
    public void onConnected(Bundle bundle) {
        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            // TODO: Consider calling
            //    ActivityCompat#requestPermissions
            // here to request the missing permissions, and then overriding
            //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
            //                                          int[] grantResults)
            // to handle the case where the user grants the permission. See the documentation
            // for ActivityCompat#requestPermissions for more details.
            return;
        } startLocationUpdates();
        mLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
        if(mLocation == null){
            startLocationUpdates();
        }
        if (mLocation != null) {
            double latitude = mLocation.getLatitude();
            double longitude = mLocation.getLongitude();
        } else {
            // Toast.makeText(this, "Location not Detected", Toast.LENGTH_SHORT).show();
        }
    }

    protected void startLocationUpdates() {
        // Create the location request
        mLocationRequest = LocationRequest.create()
                .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
                .setInterval(UPDATE_INTERVAL)
                .setFastestInterval(FASTEST_INTERVAL);
        // Request location updates
        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            // TODO: Consider calling
            //    ActivityCompat#requestPermissions
            // here to request the missing permissions, and then overriding
            //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
            //                                          int[] grantResults)
            // to handle the case where the user grants the permission. See the documentation
            // for ActivityCompat#requestPermissions for more details.
            return;
        }
        LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient,
                mLocationRequest, this);
        Log.d("reque", "--->>>>");
    }

    @Override
    public void onConnectionSuspended(int i) {
        Log.i(TAG, "Connection Suspended");
        mGoogleApiClient.connect();
    }

    @Override
    public void onConnectionFailed(ConnectionResult connectionResult) {
        Log.i(TAG, "Connection failed. Error: " + connectionResult.getErrorCode());
    }

    @Override
    public void onStart() {
        super.onStart();
        mGoogleApiClient.connect();
    }

    @Override
    public void onStop() {
        super.onStop();
        if (mGoogleApiClient.isConnected()) {
            mGoogleApiClient.disconnect();
        }
    }
    @Override
    public void onLocationChanged(Location location) {

    }

Don't forget to start GPS in your device before running app.

🌐
Alphr
alphr.com › home › how to find your gps coordinates on an android device
How To Find Your GPS Coordinates on an Android Device
July 10, 2021 - Another app to find your GPS coordinates on an Android device is the comprehensive GPS Status and Toolbox app. Marketing itself as a more serious competitor to the majority of mapping applications, this tool offers a toolbox of features for those who want more detailed location information. The position and the strength of the signals from GPS satellites
🌐
Android Developers
developer.android.com › api reference › location
Location | API reference | Android Developers
Skip to main content · English · Deutsch · Español – América Latina · Français · Indonesia · Polski · Português – Brasil · Tiếng Việt · 中文 – 简体
🌐
Medium
medium.com › @thegeospatialnews › how-to-get-gps-coordinates-of-your-location-using-your-smartphone-1de312900e1d
How to get GPS coordinates of your location using your Smartphone | by The Geospatial | Medium
August 17, 2020 - iPhone or Android users can follow these steps to get proper latitude and longitude: Go to Google Maps app on your Smartphone and enter the location for which you want coordinates.
Find elsewhere
🌐
Vogella
vogella.com › tutorials › AndroidLocationAPI › article.html
Android Location API with the fused location provider - Tutorial
February 26, 2026 - Start Google Maps on the emulator and request the current geo-position, this will allow you to activate the GPS. Send new GPS coordinates to the Android emulator.
🌐
Android Authority
androidauthority.com › home › how to get and use location data in your android app
How to get and use location data in your Android app
May 18, 2023 - You can find out what provider your passive provider actually used with the returned Location’s getProvider() method. This provides the greatest battery savings. For our app, we are going to fetch location data using the GPS provider, the NETWORK provider, and also by asking the device to decide which is the best available provider that meets a given set of criteria. Our layout has three identical segments, each of which contains: ... <TextView android:id="@+id/titleTextGPS" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" androi
🌐
DigitalOcean
digitalocean.com › community › tutorials › android-location-api-tracking-gps
Android Location API to track your current location | DigitalOcean
August 3, 2022 - The android.location has two means of acquiring location data: LocationManager.GPS_PROVIDER: Determines location using satellites.
🌐
CA
dir.ca.gov › dosh › dosh_publications › Find-coordinates-Android.pdf pdf
How to Find Your Exact Coordinates with Your Android Phone
signals to GPS satellites. If this happens, your phone uses Wi-Fi, networks, or Bluetooth devices to get your position until GPS satellites are visible
🌐
Google Play
play.google.com › store › apps › details
GPS Coordinates - Apps on Google Play
GPS Coordinates app to android to get, share, save and search map coordinates of your current location. Coordinate Converter GPS Coordinates Converter can convert any address to latitude and longitude, convert latitude longitude to an address, ...
Rating: 4.2 ​ - ​ 18.1K votes
🌐
TutorialsPoint
tutorialspoint.com › how-to-get-the-current-gps-location-programmatically-on-android-using-kotlin
How to get the current GPS location programmatically on Android using Kotlin?
November 28, 2020 - { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) title = "KotlinApp" val button: Button = findViewById(R.id.getLocation) button.setOnClickListener { getLocation() } } private fun getLocation() { locationManager = getSystemService(Context.LOCATION_SERVICE) as LocationManager if ((ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)) { ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), locationPermissionCode) } locationManager.requestLocationUpdates(LocationManage
🌐
Medium
sachankapil.medium.com › latest-method-how-to-get-current-location-latitude-and-longitude-in-android-give-support-for-c5132474c864
Latest Method: How to get Current Location (Latitude and Longitude) in Android & Give support for…
January 27, 2023 - How to get the Current Location (Latitude and Longitude) in Android This tutorial helps you to learn How to get the current latitude and longitude in the Android. As a developer when you work on …
🌐
Google Play
play.google.com › store › apps › details
My GPS Location: Realtime GPS - Apps on Google Play
April 2, 2026 - My GPS Location shows you the best available position based on location data from all current providers such as GPS, mobile networks and Wi-Fi. The app is designed for activities that require reliable real-time GPS coordinates, such as geocaching, ...
Rating: 4.4 ​ - ​ 17.2K votes
🌐
GitHub
github.com › ruboto › ruboto › wiki › Tutorial:-get-current-gps-position
Tutorial: get current gps position
require 'ruboto/widget' require 'ruboto/util/toast' require 'address_finder' ruboto_import_widgets :LinearLayout, :TextView java_import 'android.content.Context' java_import 'android.location.LocationManager' java_import 'android.content.Intent' java_import 'android.net.Uri' class GpsActivity def onCreate(bundle) super setTitle 'Ruboto GPS Example' @lm = getSystemService(Context::LOCATION_SERVICE) @ll = MyLocationListener.new(self) self.content_view = linear_layout :orientation => :vertical do linear_layout do text_view :text => 'Time: ', :id => 42 @time_view = text_view :text => '' end linear
Author   ruboto
Top answer
1 of 3
1

So here's how you can get your current location. I am skipping the permission part as you can do that yourself.

private fun isLocationEnabled(): Boolean {
        val locationManager: LocationManager =
            getSystemService(Context.LOCATION_SERVICE) as LocationManager
        return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER) || locationManager.isProviderEnabled(
            LocationManager.NETWORK_PROVIDER
        )
    }
 private fun getLastLocation() {
        if (isLocationEnabled()) {
           fusedLocationClient.lastLocation.addOnCompleteListener(this) { task ->
                val location: Location? = task.result
                if (location != null) {
                    //use the location latitude and logitude as per your use.
                    val latitude = location.latitude
                    val longitude = location.longitude
                }
            }
        }
2 of 3
0

you need to request location updates try the following for instance


    val fusedLocationProviderClient =
        LocationServices.getFusedLocationProviderClient(activity)
    val locationCallback = object : LocationCallback() {
        override fun onLocationResult(locationResult: LocationResult) {
            val location = locationResult.lastLocation
            if (location != null) {
                val latitude = location.latitude
                val longitude = location.longitude

                // Use latitude and longitude for your purposes
                Log.d("Location", "Latitude: $latitude, Longitude: $longitude")

                // Remove location updates after receiving one
                fusedLocationProviderClient.removeLocationUpdates(this)
            } else {
                Log.w("Location", "Failed to get location update")
            }
        }
    }

    if (ContextCompat.checkSelfPermission(
            activity,
            Manifest.permission.ACCESS_FINE_LOCATION
        ) != PackageManager.PERMISSION_GRANTED
    ) {
        // Request permissions if not granted
        val permissions = arrayOf(Manifest.permission.ACCESS_FINE_LOCATION)
        activity.requestPermissions(permissions, LOCATION_PERMISSION_CODE)
        return
    }

    val locationRequest =
        LocationRequest.Builder(0L).setPriority(Priority.PRIORITY_HIGH_ACCURACY).build()

    fusedLocationProviderClient.requestLocationUpdates(locationRequest, locationCallback, null)
🌐
Quora
quora.com › unanswered › How-can-we-know-our-current-location-using-an-Android-phone-and-its-GPS-facility
How can we know our current location using an Android phone and its GPS facility? - Quora
This simplest one (in terms of passive integration with Android) is to use Google Location Services. Enabling location services as part of your Google profile will allow Google to periodically interrogate your location via the phone’s GPS ...