I just did a bunch of trial-and-error research with the various location libs (FLP, LM, GPS) and I came across an issue with the Fused Location Provider as used in this example app:
Some background....Basically, the location setting on a user's device can be put into one of three modes:
1) GPS - In this mode it uses *just* the built-in GPS receiver in the device to determine the devices location. Apparently this method uses a significant amount of power.
2) Network - In this mode it uses WiFi, Bluetooth and the cellular networks to determine the devices location. This mode uses less power then the GPS mode.
3) High Accuracy - In this mode, it will use both modes 1 and 2 to determine the devices location.
Mode's 2 and 3 use google services, and as such, it will require the user to agree to allow google to track their device 24/7 even when there are no location apps running on the device. If the user does not agree with these terms, the mode is set back to mode 1 (GPS only).
The problem I am running into is that if my device is set to "GPS only" (mode 1), then it seems I can't use the FLP library. I say this because when I click "START" in the above demo app, it will first ask for location permission - easy enough to understand why and I grant it. The example app then asks me for "Resolution Required" permission, which has a drop down arrow that expands and explains that this second permission will allow google to track my device 24/7 even if I don't run any location apps. If I say "No Thanks", it will stop and display "Not Enabled" and wont display my location as if the lib can't run this way. NOTE: Answering "OK" to this second prompt will *permanently* change the user's device location setting to mode 3 - and I don't know if the user will correctly realize this change will effect ALL apps DEVICE-WIDE and not just for your app.
So, it appears, unless the user is willing to let google track them full-time, your app can not use this FLP lib to determine the devices location if it is in "GPS Only" mode.
I was hoping that this lib would still be able to work on devices in mode 1, but would just only use the GPS to determine location and wont use networks.
In an attempt to see if I could get this FLP lib to work in GPS only mode, I tried all different combinations of having Coarse and Fine permissions in the manifest and trying the different priority settings in the LocationRequest:
Am I missing something that will allow this lib to be used even if the device is in mode 1?
If this FLP lib is designed to only work in mode 2 or 3, then this means that your app will also need to include one of the other location libs (LM,GPS) for the situations that the user's device is in GPS only mode 1 so that the user is not forced to give up their privacy in order to use your app.
FusedLocationProvider + Resolution Dialog
** This is the only option to enable location services from inside your app. ** Example was updated and is based on B4XPages. Don't miss: 1. ShowResolutionDialog sub that is added to Main. It needs to be added to the activity that hosts B4XPages. 2. #AdditionalJars in Main. 3. Manifest editor...
www.b4x.com
Some background....Basically, the location setting on a user's device can be put into one of three modes:
1) GPS - In this mode it uses *just* the built-in GPS receiver in the device to determine the devices location. Apparently this method uses a significant amount of power.
2) Network - In this mode it uses WiFi, Bluetooth and the cellular networks to determine the devices location. This mode uses less power then the GPS mode.
3) High Accuracy - In this mode, it will use both modes 1 and 2 to determine the devices location.
Mode's 2 and 3 use google services, and as such, it will require the user to agree to allow google to track their device 24/7 even when there are no location apps running on the device. If the user does not agree with these terms, the mode is set back to mode 1 (GPS only).
The problem I am running into is that if my device is set to "GPS only" (mode 1), then it seems I can't use the FLP library. I say this because when I click "START" in the above demo app, it will first ask for location permission - easy enough to understand why and I grant it. The example app then asks me for "Resolution Required" permission, which has a drop down arrow that expands and explains that this second permission will allow google to track my device 24/7 even if I don't run any location apps. If I say "No Thanks", it will stop and display "Not Enabled" and wont display my location as if the lib can't run this way. NOTE: Answering "OK" to this second prompt will *permanently* change the user's device location setting to mode 3 - and I don't know if the user will correctly realize this change will effect ALL apps DEVICE-WIDE and not just for your app.
So, it appears, unless the user is willing to let google track them full-time, your app can not use this FLP lib to determine the devices location if it is in "GPS Only" mode.
I was hoping that this lib would still be able to work on devices in mode 1, but would just only use the GPS to determine location and wont use networks.
In an attempt to see if I could get this FLP lib to work in GPS only mode, I tried all different combinations of having Coarse and Fine permissions in the manifest and trying the different priority settings in the LocationRequest:
B4X:
Private Sub CreateLocationRequest As LocationRequest
Dim lr As LocationRequest
lr.Initialize
lr.SetInterval(0)
'lr.SetPriority(lr.Priority.PRIORITY_HIGH_ACCURACY)
'lr.SetPriority(lr.Priority.PRIORITY_BALANCED_POWER_ACCURACY)
Return lr
End Sub
Am I missing something that will allow this lib to be used even if the device is in mode 1?
If this FLP lib is designed to only work in mode 2 or 3, then this means that your app will also need to include one of the other location libs (LM,GPS) for the situations that the user's device is in GPS only mode 1 so that the user is not forced to give up their privacy in order to use your app.
Last edited: