Home Coding Android Coding How to Get the Current Location in Android

How to Get the Current Location in Android

1

gps_locations

This post will feature a simple Android application that will display the current location in latitude and longitude. This is achieved with the help of the GPS function and the LocationManager API. You can follow the steps down below to recreate an app in Android Studio that is capable of fetching the current location and display it on the screen.

How to Get the Current Location in Android Studio

1. Create a New Android Studio Project.

1

2. Open SDK Manager and check whether you have Google Play Services installed. If not, go to SDK Tools and download Google Play Services.

2

3. Add the following code into AndroidManifest.xml:

4.  Insert the following code into MainActivity.java:

5.  Add the following code into activity_main.xml :

6. This is how our strings file looks like:

7. Run the app. It should display the location in latitude and longitude.

13499939_1737263879845231_1239540512_o

You can download the source code by clicking the link below.

Download Source Code
Denis Madroane App junkie, Android developer, proud Freelancer. Passionate about app development and blogging, updated with the new stuff. Likes to think that he's versed in app re-skinning, content writing and social media.

Comment(1)

LEAVE YOUR COMMENT

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

Powered by WordPress