Licensing Library - 'The Bottom Line'

rtesluk

Member
Licensed User
Longtime User
July 20 2012
05:00 Hours

There have been many threads on this forum pertaining to the correct use of this Library that I am utterly confused.

I have published two free apps

TweetChirp Assistant Help 2.0
TweetChirp Field Guide Help 1

The first one works with the Licensing Libary the second does not, even though I am using the same code.

I can use the same code because the apps are help apps for two other apps I have created - one is published and other is about to be published.

I always get with the first app, response Sub lc_Allow.......End Sub
I always get with the second app, response Sub lc_DontAllow...End Sub

I cannot upload my zipped apps because that would exposed my publicKey.

I must be doing something wrong.

What is the BEST way to use this Library? - 'The Bottom Line'

Ray Tesluk Port Hope Canada :sign0085:

Here is my code

B4X:
Sub Process_Globals
.
.
.
    Dim publicKey As String
    publicKey = "MIIBIjANBgkqh....."
    Dim s_Test As String
End Sub

Sub Globals
.
.
.
Dim lc As LicenseChecker
End Sub

Sub Activity_Create(FirstTime As Boolean)
.
.
.
    lc.Initialize("lc", GetDeviceId, publicKey, "qwertyuiopa".GetBytes("UTF8"))
    lc.SetVariableAndValue("s_Test",SlideShow.sSecret)
    lc.CheckAccess

End Sub

Sub lc_Allow
    Log("lc_Allow->Allow")
    ToastMessageShow(s_Test & " lc_Allow", True)
End Sub
Sub lc_DontAllow
    Log("lc_DontAllow->DontAllow")
    ToastMessageShow(s_Test & " lc_DontAllow", True)
    'Activity.Finish
End Sub
Sub lc_Error (ErrorCode As String)
    Log("lc_Error->ErrorCode " & ErrorCode)
    ToastMessageShow(ErrorCode & " " & s_Test & " lc_Error", True)
    'Activity.Finish
End Sub

Sub GetDeviceId As String    
Dim r As Reflector    
Dim Api As Int    
Api = r.GetStaticField("android.os.Build$VERSION", "SDK_INT")    
If Api < 9 Then        'Old device        
   If File.Exists(File.DirInternal, "__id") Then            
      Return File.ReadString(File.DirInternal, "__id")        
   Else            
      Dim id As Int            
      id = Rnd(0x10000000, 0x7FFFFFFF)            
      File.WriteString(File.DirInternal, "__id", id)            
      Return id        
   End If    
Else        'New device        
   Return r.GetStaticField("android.os.Build", "SERIAL")    
End If
End Sub
 

rtesluk

Member
Licensed User
Longtime User
Licensing Library

Thank you for replying.

I wanted to 'test' the licensing scheme before I commit myself to a paid app.

It's more like a trial as well as a learning experience.

Ray
 
Upvote 0

rtesluk

Member
Licensed User
Longtime User
Found The Answer

If the app is not published then the market service will not be able to validate the installation (unless you use the market developer feature as described in the tutorial).

BTW, this help app has been published.

All I had to do was to uninstall Tweet Guide Help from my phone then re-install it from Google Play unto my phone.

Now the response is Sub lc_Allow ... End Sub.

So if I DON'T change the Licensing scheme but add other features to the app it should continue to work properly; that is the licensing response should be Sub Ic_Allow ... End Sub.

But if I change the licensing scheme. for example

lc.Initialize("lc", GetDeviceId, publicKey, "qwertyuiopa".GetBytes("UTF8"))

to

Dim PH as Phone

lc.Initialize("lc", PH.GetSettings('"android_id"), publicKey, "qwertyuiopa".GetBytes("UTF8"))

it should not work.

I think that I should stick to one Licensing scheme.

Ray :sign0104:
 
Upvote 0
Top