Here is the demo video of the running app.
In this tutorial, we will do the following tasks:
- Get the last known location using google fused api.
- If no data is available, we'll request for the current geolocation updates.
- Add check for enabling location services of the device.
After that add the dependency in the build.gradle(App Module) file:
compile 'com.google.android.gms:play-services:10.0.1'
set up complete for using the getting current location using google fused api.
compile 'com.google.android.gms:play-services:10.0.1'
set up complete for using the getting current location using google fused api.
Add permissions in AndoidManifest,xml
You can get the complete project at Github Repository. Or you can get the code below in this post.
All done, just add the following code in your MainActivity.java
And the following code in your main_activity.xml
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
You can get the complete project at Github Repository. Or you can get the code below in this post.
All done, just add the following code in your MainActivity.java
And the following code in your main_activity.xml
Its a good tutorial covering all stuff to get current location. Can you post a tutorial for showing you current location on google maps too?? That'd be great!
ReplyDeleteThanks!
Thanks for appreciating the effort!
DeleteSure I'll post a tutorial about google maps activity shortly.
I didnt get Lat Lon
ReplyDeleteCan you please share the error? Meanwhile check if you have added permissions in androidmenifest.xml
DeleteIn the emulator and on a Galaxy S7 the LAT/LONG are never displayed. The working dial spins but never stops. If I turn off location the App asks to turn it on and that happens.
DeleteAny suggestions about how to correct this issue?
Thank you,
Richard
Working on Lollipop, but not on Marshmallow and Nougat. Tried to add in code permission - didn't help. Any suggestion what could go wrong. Thanks.
ReplyDeletecompile 'com.google.android.gms: play-services: 10.0.1'
ReplyDeletekenapa kok setiap kali gradle eror?? butuh pencerahan
it doesnt show location with gps only?
ReplyDeleteHow can we get the distance between two locations using this same example?
ReplyDeleteIs it possible to get the location name as well with lat and long?
ReplyDelete