Get Current Location Android -No GPS and Internet

Get Current Location Android -No GPS and Internet:-

Get Current Location Android – No Gps and Internet, There are different ways by which we can get users current location in android.Get Current Location Android no GPS and Internet, we are using   FusedLocationProviderClient . Its a battery efficient API introduced by Google.Using devices multiple sensors in a best possible way to is the ideal advantage of this API.Let’s go ahead and start .



Create Project:
Go to File->Create New project . Then add a location-based play-services-location dependency in your app.gradle .

Create activity_main.xml:-

Update manifest.xml with following permissions:-



We need users permission to access users device and the permissions are of two types .We are taking both permissions.

Now Add the following piece of Code in MainActivity.java




MainActivity.java:-

Once user permission is given we get device location and show on UI.But if a user rejects the app asking permisiions we again re-prompt user to provide permission. Now if the user selects checkbox Do not Ask again then we redirect the user to app settings page and let him provide permission.




Download Source Code

 

Deploy React JS in Tomcat

Spring Boot Jersey Example

1 thought on “Get Current Location Android -No GPS and Internet

Leave a Reply

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