Hello,
I have a B4A app working 100% and now I want to send it to google play, so I need to use the Licensing Library. I have tested the library and examples, and all worked ok, but now, when I need to integrate it to my application, I'm having some troubles.
The main problem is, I don't want to change the program workflow, so I want to create a new sub, called LicenseCheck, that would be called the first time the activity create sub run, and then I could proceed to the rest of the program.
But, the approach I used, doesn't seems to work, because the Licence Check process is asynchronous, that means, I call the LicenseCheck routine, but the program doesn't stop to wait for the answer, and keeps running.
I tried a do until loop checking for the value of a global variable, but even using the DoEvents statement, the program stops responding.
Can someone give some idea?
Thank you all.
I have a B4A app working 100% and now I want to send it to google play, so I need to use the Licensing Library. I have tested the library and examples, and all worked ok, but now, when I need to integrate it to my application, I'm having some troubles.
The main problem is, I don't want to change the program workflow, so I want to create a new sub, called LicenseCheck, that would be called the first time the activity create sub run, and then I could proceed to the rest of the program.
But, the approach I used, doesn't seems to work, because the Licence Check process is asynchronous, that means, I call the LicenseCheck routine, but the program doesn't stop to wait for the answer, and keeps running.
I tried a do until loop checking for the value of a global variable, but even using the DoEvents statement, the program stops responding.
Can someone give some idea?
Thank you all.
B4X:
......
Sub Process_Globals
Dim publicKey As String
publicKey = "MIIBIjANBgkqhkiG9..."
Dim test_1 As String
Dim licensed = False
End Sub
Sub LicenseCheck
Dim lc As LicenseChecker
Dim p As PhoneId
lc.Initialize("lc", p.GetDeviceId, publicKey, "kljdflkf".GetBytes("UTF8"))
lc.SetVariableAndValue("test_1", "some secret value")
lc.CheckAccess
End Sub
Sub lc_Allow
Log("Allow")
licensed = True
Activity_Create(False)
End Sub
Sub lc_DontAllow
Log("DontAllow")
ToastMessageShow("Closing application.", True)
Activity.Finish
End Sub
Sub lc_Error (ErrorCode As String)
Log("error: " & ErrorCode)
ToastMessageShow("Closing application.", True)
Activity.Finish
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then LicenseCheck
Do Until licensed
DoEvents
Loop
.......