Android Question Permissions and Google Maps and FusedLocationProvider

JMB

Active Member
Licensed User
I am trying to get the Google Maps/FusedLocationProvider example to work, but I am finding the Permissions thing a bit confusing.

I've modified one of the functions so that it looks like this:

B4X:
Sub Mapfragment1_Ready
    gmap = MapFragment1.GetMap
    rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
    If gmap.IsInitialized Then
'        Wait For LocationSource_Ready (Success As Boolean)
'        If Success Then
'            Log("Ready!!!")
'            Dim jo As JavaObject = gmap
'            jo.RunMethod("setLocationSource", Array(Starter.LocationSource))
'        End If
    End If
End Sub
In order to try and get it working, I have commented out the position injection section, but I am still getting a security error appearing, even though the dialog asking for permission shows up once I have cleared the "Your app appears to have crashed" dialog.

How do I get the code to wait until the permission is given before showing the map and injecting the location?

I've read the tutorial on permissions, but I am still unclear as to how to get the code to wait until the permission is granted before moving on to presenting the map and injecting the location using FusedLocationProvider.

Thanks for any help.

JMB
 

DonManfred

Expert
Licensed User

JMB

Active Member
Licensed User
Thanks for that Manfred.

I have tried using that code but it doesn't seem to work. I shall investigate more fully. Just on my way home from work - takes about a day!

Thanks for your help.

JMB
 

JMB

Active Member
Licensed User
Well it looks like I must have been using an old version of GoogleMaps perhaps because my API key was ok, but downloading the version of code that Manfred pointed me to has resulted in working code. Amazing what you can do while on the train home.

So I shall persevere with integrating with FusedLocationProvider!

Thank you - there may be more to follow...
 

JMB

Active Member
Licensed User
I get it to work but it tells me that the module is from a newer version - I am running B4A 9.30 which I thought was the latest version...

Apart from that minor item, the code works. I guess I've been using an out of date version.

Thank you!
 
Last edited:

JMB

Active Member
Licensed User
Aha! I am very glad that it is working now - I was tearing my hair out! Thanks Erel.
 
Top