Android Question [Solved]FusedLocation Resolution Dialog Not working

AndroidMadhu

Active Member
Licensed User
Hello,
I am following the below link for GPS enabled service at B4xPages.

https://www.b4x.com/android/forum/threads/fusedlocationprovider-resolution-dialog.111652/

But when I am enabling GPS service at the device the dialog is not showing. Whereas the below code is running at B4A and the GPS enabled dialog is showing as expected.
I am running the same code at B4xPages, but the resolution dialog is not showing.
B4X:
Log("gps check")
rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
If Starter.flp.IsConnected = False Then
SetState("Location provider not available")
End If
If Result Then
Dim rs As ResumableSub = Starter.CheckLocationSettingStatus() 'CallSub(Starter, "CheckLocationSettingStatus")
Wait For (rs) Complete (SettingsResult As LocationSettingsResult)
Dim sc As StatusCodes
Select SettingsResult.GetLocationSettingsStatus.GetStatusCode
Case sc.SUCCESS
SettingsAreGood
Case sc.RESOLUTION_REQUIRED
SetState("RESOLUTION_REQUIRED")
SettingsResult.GetLocationSettingsStatus.StartResolutionDialog("srd")
Wait For srd_ResolutionDialogDismissed(LocationSettingsUpdated As Boolean)
If LocationSettingsUpdated Then
SettingsAreGood
Else
SetState("Not enabled")
End If
Case Else
SetState("Not available")
End Select
Else
SetState("No permission")
End If

Please advice

Thanks
 

AndroidMadhu

Active Member
Licensed User
Does the example, without making any changes, work for you?
@Erel ..... It is working perfectly at B4A, but when I am implementing the same code at B4Xpages, the Dialog [attached picture below] is not showing....

1611760419448.png


Thanks
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
It has something to do with the way FLP handles the event.

Workaround:
B4X:
'B4XMainPage:
Sub Button1_Click
    rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
    Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
    If Starter.flp.IsConnected = False Then
        SetState("Location provider not available")
    End If
    If Result Then
        Dim rs As ResumableSub = Starter.CheckLocationSettingStatus 
        Wait For (rs) Complete (SettingsResult As LocationSettingsResult)
        Dim sc As StatusCodes
        Select SettingsResult.GetLocationSettingsStatus.GetStatusCode
            Case sc.SUCCESS
                SettingsAreGood
            Case sc.RESOLUTION_REQUIRED
                SetState("RESOLUTION_REQUIRED")
                CallSub2(Main, "StartResolutionDialog", SettingsResult)
                Wait For LocationSettings_Updated (LocationSettingsUpdated As Boolean)
                If LocationSettingsUpdated Then
                    SettingsAreGood
                Else
                    SetState("Not enabled")
                End If
            Case Else
                SetState("Not available")
        End Select
    Else
        SetState("No permission")
    End If
End Sub

B4X:
'Main
Public Sub StartResolutionDialog (SettingsResult As LocationSettingsResult)
    SettingsResult.GetLocationSettingsStatus.StartResolutionDialog("srd")
    Wait For srd_ResolutionDialogDismissed(LocationSettingsUpdated As Boolean)
    CallSubDelayed2(B4XPages.MainPage, "LocationSettings_Updated", LocationSettingsUpdated) 'change page if needed
End Sub
 
Upvote 0
Top