First you need to define a LocationListener to handle location changes.

int LOCATION_REFRESH_TIME = 15000; // 15 seconds to update
int LOCATION_REFRESH_DISTANCE = 500; // 500 meters to update

....

private final LocationListener mLocationListener = new LocationListener() {
    @Override
    public void onLocationChanged(final Location location) {
        //your code here
    }
};

Then get the LocationManager and ask for location updates

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE);

    mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, LOCATION_REFRESH_TIME,
            LOCATION_REFRESH_DISTANCE, mLocationListener);
}

And finally make sure that you have added the permission on the Manifest,

For using only network based location use this one

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

For GPS based location, this one

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
Answer from Axxiss on Stack Overflow
🌐
Google
developers.google.com › google maps platform › android › maps sdk for android › select current place and show details on a map
Select Current Place and Show Details on a Map | Maps SDK for Android | Google for Developers
In Android Studio, select File > New > Import Project. Go to the location where you saved the Google Maps Android API v2 Samples repository after downloading it. Find the CurrentPlaceDetailsOnMap project at this location: PATH-TO-SAVED-REPO/android-samples/tutorials/java/CurrentPlaceDetailsOnMap (Java) or PATH-TO-SAVED-REPO/android-samples/tutorials/kotlin/CurrentPlaceDetailsOnMap (Kotlin)
Discussions

position - how to get current Location with android studio - Stack Overflow
I want get current location then i press one button in the app but it dont give me that instead it give unknown address but if i change my location to USA it gives the address? I dont get any errors More on stackoverflow.com
🌐 stackoverflow.com
java - Getting current location in Android Studio app - Stack Overflow
I am developing my first Android app which should get the latitude and longitude of an android device and send it via a web service to a template document. I followed the guide of getting the loca... More on stackoverflow.com
🌐 stackoverflow.com
java - How to find my current location in android studio using Google Maps API? - Stack Overflow
Basically, I wrote code for finding my current location and I am using Android 10.0 and API 30 and the latest Android Studio version. and all the SDK tools are installed, but when I start the program, it doesn't show me my location, it shows google's headquarter location. and this is my function to find my location: Copyprivate void getDeviceLocation... More on stackoverflow.com
🌐 stackoverflow.com
Is there any non-complicated way of fetching current location in Android
A combination of these two solutions perhaps with a few modifications: https://medium.com/@munbonecci/how-to-get-your-location-in-jetpack-compose-f085031df4c1 https://github.com/googlemaps/android-maps-compose/blob/main/app/src/main/java/com/google/maps/android/compose/LocationTrackingActivity.kt More on reddit.com
🌐 r/androiddev
6
0
May 13, 2024
🌐
Google
codelabs.developers.google.com › codelabs › while-in-use-location
Receive location updates in Android with Kotlin | Google Codelabs
March 27, 2026 - This method requires such a block ... user taps the button. If you wish to see it, have a look at the MainActivity.kt class. Run your app from Android Studio and try the location button....
🌐
Stack Overflow
stackoverflow.com › questions › 64951824 › how-to-get-current-location-with-android-studio
position - how to get current Location with android studio - Stack Overflow
try { Geocoder geo = new Geocoder(this.getApplicationContext(), Locale.getDefault()); List<Address> addresses = geo.getFromLocation(currentLocation.getCoordinates().latitude, currentLocation.getCoordinates().longitude, 1); if (addresses.isEmpty()) { autocompleteFragmentFrom.setText(R.string.waiting_for_location); } else { addresses.size(); if (addresses.get(0).getThoroughfare() == null) { pickupLocation.setName(addresses.get(0).getLocality()); } else if (addresses.get(0).getLocality() == null) { pickupLocation.setName("unknown address"); } else { pickupLocation.setName(addresses.get(0).getLoca
🌐
GitHub
github.com › Akashmathwani › Get-Current-Location-Android
GitHub - Akashmathwani/Get-Current-Location-Android: get Current latitude and Longitude in android studio code.
get Current latitude and Longitude in android studio code. - Akashmathwani/Get-Current-Location-Android
Starred by 5 users
Forked by 3 users
Languages   Java 100.0% | Java 100.0%
🌐
TutorialsPoint
tutorialspoint.com › how-to-get-current-location-latitude-and-longitude-in-android
How to get current location latitude and longitude in Android?
August 30, 2019 - <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:gravity="center" tools:context=".MainActivity"> <TextView android:id="@+id/showLocation" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="Location" android:textSize="24sp" /> <Button android:id="@+id/btnGetLocation" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Get Location" /> </LinearLayout>
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-get-current-location-in-android
How to Get Current Location in Android? - GeeksforGeeks
There are two ways to get the current location of any Android device: ... Question: Which one is efficient and why? Answer: Fused Location Provider because it optimizes the device’s use of battery power. Before moving any of the above methods we will have to take location permission. To create a new project in the Android Studio...
Published   April 7, 2025
🌐
YouTube
youtube.com › watch
How to Get Current Location on Google Map in Android Studio | Step by Step Google Maps Tutorial - YouTube
In this tutorial video, you will learn how to get your current location on Google Maps in Android Studio. The video provides a step-by-step guide on how to i...
Published   March 23, 2023
🌐
Javapapers
javapapers.com › android › get-current-location-in-android
Get Current Location in Android - Javapapers
Hi, How can i scan barcodes in android application! ... yes u can use barcode scan u will find source code for barcode scan check it in github repository once i used zxing(a barcode scanner Engine) ... […] we studied about how to get current geographic location using an android application.
🌐
Google
developers.google.com › google maps platform › android › maps sdk for android › location data
Location Data | Maps SDK for Android | Google for Developers
CurrentPlaceDetailsOnMap: Finding the current location of an Android device and displaying details of the place (business or other point of interest) at that location.
Top answer
1 of 4
2

I have written detailed tutorial covering this topic here on demonuts.com.You can find more description here and also you can download whole demo source code for better understanding.

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.

2 of 4
1

You need to define LocationListener .

public class MainActivity extends Activity implements LocationListener{
    protected LocationManager locationManager;
    protected LocationListener locationListener;
    protected Context context;
    TextView txtLat;
    String lat;
    String provider;
    protected String latitude,longitude; 
    protected boolean gps_enabled,network_enabled;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        txtLat = (TextView) findViewById(R.id.textview1);

        locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
    }
    @Override
    public void onLocationChanged(Location location) {
        txtLat = (TextView) findViewById(R.id.textview1);
        txtLat.setText("Latitude:" + location.getLatitude() + ", Longitude:" + location.getLongitude());
    }

    @Override
    public void onProviderDisabled(String provider) {
        Log.d("Latitude","disable");
    }

    @Override
    public void onProviderEnabled(String provider) {
        Log.d("Latitude","enable");
    }

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {
        Log.d("Latitude","status");
    }
}

And need to give below permission :

ACCESS_COARSE_LOCATION : It is used when we use network location provider for our Android app.

ACCESS_FINE_LOCATION : It is providing permission for both providers.

INTERNET : permission is must for the use of network provider.

🌐
Stack Overflow
stackoverflow.com › questions › 62467337 › how-to-find-my-current-location-in-android-studio-using-google-maps-api
java - How to find my current location in android studio using Google Maps API? - Stack Overflow
Basically, I wrote code for finding my current location and I am using Android 10.0 and API 30 and the latest Android Studio version. and all the SDK tools are installed, but when I start the program, it doesn't show me my location, it shows google's headquarter location. and this is my function to find my location: Copyprivate void getDeviceLocation() { final LocationRequest locationRequest = new LocationRequest(); locationRequest.setInterval(1000); locationRequest.setFastestInterval(3000); locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); LocationServices.getFusedLocationP
🌐
GitHub
github.com › Pritish-git › get-Current-Location › blob › main › MainActivity.java
get-Current-Location/MainActivity.java at main · Pritish-git/get-Current-Location
import com.google.android.gms.location.LocationCallback; · import com.google.android.gms.location.LocationRequest; · import com.google.android.gms.location.LocationResult; · import com.google.android.gms.location.LocationServices; · ...
Author   Pritish-git
🌐
GitHub
github.com › farooqkhan003 › android-current-location
GitHub - farooqkhan003/android-current-location: Android App getting current Location using Google Fused Api.
Android App for getting current Location using Google Fused Api. And if no previous data for location is available, it gets the current location. Here you can see the Demo Video.
Starred by 13 users
Forked by 11 users
Languages   Java 100.0% | Java 100.0%
🌐
Quora
quora.com › How-do-I-find-the-users-current-location-in-Android-Studio
How to find the user's current location in Android Studio - Quora
Answer (1 of 3): got a nice tutorial here which is using fused location provider api http://www.askfortricks.com/2016/03/get-location-in-android-using-fusedlocationprovider-api-or-make-android-app-location-aware/
🌐
DigitalOcean
digitalocean.com › community › tutorials › android-location-api-tracking-gps
Android Location API to track your current location | DigitalOcean
August 3, 2022 - You can connect your smartphone and run the application in debug mode to check your current location. To emulate GPS Locations in an emulator we can pass fixed Latitude and Longitude values from Android Studio. Besides the emulator window, you can see a list of options.
🌐
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 · 中文 – 简体
🌐
W3Docs
w3docs.com › java
How to get current location in Android
import android.location.Location; import android.location.LocationManager; public class MainActivity extends AppCompatActivity { private LocationManager locationManager; private Location currentLocation; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); } @Override protected void onResume() { super.onResume(); requestLocationUpdates(); } @Override protected void onPause() { super.onPause(); removeLocationUpdates(); } private void reque
🌐
GeeksforGeeks
geeksforgeeks.org › android › how-to-get-user-location-in-android
How to get user location in Android - GeeksforGeeks
July 15, 2025 - Once the LocationRequest object is ready, set it on the FusedLocationProviderClient object to get the final location. Let's now look at the MainActivity.java file. ... import android.Manifest; import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.location.Location; import android.location.LocationManager; import android.os.Bundle; import android.os.Looper; import android.provider.Settings; import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; impo