Current Location Android Kotlin With Latitude Longitude Programmatically

It is necessary to find Current Location Android Kotlin latitude longitude programmatically when you are developing location-based applications.

For example, when finding restaurants near by you, you need your current location, latitude and longitude.

In Current Location Android Kotlin example tutorial, you will learn to get current latitude and longitude of Android device.

We will use Google’s FusedLocationAPI for getting current location latitude longitude.

Following is the output of Current Location Android Kotlin example tutorial programmatically:

Download Source Code For Current Location Android Kotlin Example

Try Our App

Download DemoNuts app to learn anytime, anywhere: Download DemoNuts Android App

Or search “demonuts” in play store from android mobile device.

Getting current GPS location android :

If you are using adblocker, then you will not be able to show our site smoothly. For example, you find step 6 after step 1 or similar to this. So please disable adblocker to fully utilize all resources of DemoNuts

Step 1.  Create a new project in Android Studio.

Step 2. In build.gradle(Module:app) file put this:

Step 3.  Implement necessary interfaces

Step 4. Declare instances:

Step 5.  Put following in onCreate() function:

Step 6. Override necessary methods.

Step 7.  Last but not least, put required permissions in AndroidManifest.xml:

If you are targeting marshmallow and after versions (targetSdkVersion >=23) then you have to check for run-time permissions.

You can learn about this topic here at our separate example.

Now full source code:



Step 7.  Full Source code for MainActivity.



In above class, there is a method

This method is used to check whether location service is on or off in your phone. If off, then it will pop up one dialog, which will take the user to settings to enable location service.

Java Version

Java Version of this tutorial is present at : Current GPS Location Android

How to get exact Android example while searching in Google

When you search for any Android example in Google, always add “Android Studio programmatically” at the end of your query.

Why add studio?

If you search with the query “Facebook login in Android” then Google will also show you examples which are developed with Eclipse. Examples made with Eclipse are useless because it is officially deprecated.

Put studio in your query, and it becomes “Facebook login in Android Studio.

Why add programmatically

If your query is “Scan barcode in Android” then Google will show you some app URLs to play store which helps the user to scan the barcode.

Google doesn’t know that you are looking for source code to implement scan in Android.

Now if your query is “Scan barcode in Android Studio programmatically” then google will show you examples which are developed with android studio and will also remove app URLs of play store.

Thus adding Android Studio programmatically will save your lot of time in searching right tutorial.
That’s all for getting current GPS location android tutorial. Now if you run this demo, you will get output latitude and longitude as shown in the video.


Other charming tutorials you will definitely like

Cheers and keep healthy coding!

Hardik Parsania

I am mobile app developer. I am always passionate about solving complex and real world problems.I have developed many apps with great interest and superior logical skills.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *