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
