Android Question GetScheduleExactAlarmPermission always return False in first time

asales

Expert
Licensed User
Longtime User
When I use this code (from this example):
B4X:
Wait For (GetScheduleExactAlarmPermission) Complete (HasPermission As Boolean)
Log("HasPermission: " & HasPermission)

In Android 14 I always get False to HasPermission in the first time, even I set the permission to true.

When I click again, I can see the permission was granted and HasPermission returns True.

How can I get the correct return to HasPermission in first time?

Thanks in advance for any tips.
 

drgottjr

Expert
Licensed User
Longtime User
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
ok. i can run erel's example on android 12 and android 14 without the double message. since you went with b4xpages and i didn't, i have to assume there is an issue there (although i have no idea what). if you decide to try it with a "classic" b4a app, you need to modify the example (per erel):

B4X:
'b4xpages
'Sub GetBA As Object
'    Dim jo As JavaObject = Me
'    Return jo.RunMethod("getBA", Null)
'End Sub

'If not using B4XPages, replace GetBA with:
Sub GetBA As Object
    Dim jo As JavaObject
    Dim cls As String = Me
    cls = cls.SubString("class ".Length)
    jo.InitializeStatic(cls)
    Return jo.GetField("processBA")
End Sub

maybe erel (or someone who has encountered the same issue) will spot this thread and comment. sorry.
 
Upvote 0

asales

Expert
Licensed User
Longtime User
I'm using a b4xpage project in an emulator with Android 14, to test this functionallity.
I still get this same behavior (don't shows the permission, even was granted, in first time) in an activity project too.
But I'm grad to your support. Thanks again @drgottjr.
 
Upvote 0
Top