Introduction and usage for Location Services
Yes you read it right. When we start Mobile application development on Android , user remains king when it comes to location permissions. To maintain this analogy Developers Community around the world came up with a concept where if android application uses location permissions application should be asking user to whether it can use GPS services or asking user to turn on GPS.
So on device having Android OS less than Android 6.0, an application if try to use GPS permission by declaring in Android Manifest.xml as COARSE_LOCATION permission and Fine Location Permission, then user should be greeted with the image. [ Of course we need to implement this in our android application. ] .
I don’t want to confuse my reader so to know the implementation for this please visit my another blog.
so once GPS was turned on when our application requested from user , our application can use location services to fetch location. or In addition to this our application can successfully use a nice API by Places Picker in Google Places API
So whatever I have said as of now is application to Devices having Android OS version less that Android 6.0 aka Android Marshmallow.
For Android Marshmallow
The situation becomes slightly complex [ Not to worry its very easy] when we are Starting Android development on Android Marshmallow devices.
So scenario is same our application is try to access location. So as per Android Marshmallow , application should ask user at runtime if Application is trying to use any of the permission listed in Dangerous permission groups as by Android.
More information on Dangerous permission group in Android can be found here.
Now user can choose to allow or disallow location permission for application. So we as application developer handle this like when user allows a permission then only he or she can use service provided by our application else we will ask user to provide location permission.
code implementation for the above would be described in another blog post.
So if user allow application to use location services [ considering location is turned on and proper permission are declared in android manifest] , application can fetch location results.
For eg in Google Place API , you have option called Select this location. To get proper result we need to have location permission as already described earlier else we will be getting some default values and most of the time it won’t be that one which user is expecting.
Soon I will update links to my other blog references in post.
Stay tuned and Happy Coding.