Licensing Library workflow

demasi

Active Member
Licensed User
Longtime User
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.

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

   .......
 

demasi

Active Member
Licensed User
Longtime User
Thank you Erel, I've got the point.
but I don't know what is a "non-cancelable progress dialog". this is the B4A progress bar?
 
Upvote 0

demasi

Active Member
Licensed User
Longtime User
Thank you, Erel. I found it, and i used, but what is happening is, the application keeps running untl the license test completes, and, case DontAllow, the program is aborted.
What I want to avoid, is this, the applicatios begins to run and show the main screen.
This is why I tried to stop the program untl the license check is complete.
Where is the normal place to use the License Check? Where I must put, or, where is the best, the most used place developers use to do the license checK. Is this in the activity create sub? I see, at my knowledge level, various program flow problems using this way.
 
Last edited:
Upvote 0
Top