In General few apps require user location, there we can enter address in a edittext field but as to get much more flexibility we can fetch the current latitude and longitude details based on user location. i.e., we can fetch latitude and longitude values from gps based on location of user we fetch these values.

 

Many apps now a days like taxi apps which will show their cabs present locations based on these values and also there are many different types of usages.

 

So lets get started with Android Fetch Current Latitude and Longitude Values

 

Before getting further we will get values based on network provider also.

Now we need to check GPS is enabled or not

 

Now checking with Network

 

 

Checking with GPS

 

 

FetchLocation.java

 

 

 

 

MainActivity.java

 

Now we will fetch the methods getLatitude and getLongitude  and show output in MainActivity.java

 

 

And then

 

activity_main.xml

Here we are adding two textviews and a button to fetch values on click.

 

 

AndroidManifest.xml

 

Adding required permission in manifest file like internet and access fine location.

 

 

 

Output :

latlonbanner

If you like the tutorial do share and like us for more android tutorials.

Show Buttons
Hide Buttons
Read previous post:
Android Tutorial On Textview Marquee Animation

Close