Android Question Protect app

Phsoftware_app

Member
Licensed User
Longtime User
Hy,
i see that with sdk16 in not more necessary to use license library,is right?
But how have sdk<16?
 

afields

Member
Licensed User
Hy,
i see that with sdk16 in not more necessary to use license library,is right?
But how have sdk<16?
hello. sdk less then 16 is not more in the sdk manager, so you'll have to search for that number. however with that sdk there will be some programs that will not work at all...
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can use the licensing library with all versions.
It will add protection, especially if you use the SetVariableAndValue.

Starting from Android 4.1 (API 16) the apps downloaded from Google Play are encrypted and will only work on the device that they were downloaded to. However it can still be useful to add the licensing library.
 
Upvote 0

Phsoftware_app

Member
Licensed User
Longtime User
ah! ok!
But some time with the license library ( i use 1.21) if there is no connections,the app say (i write that) "app not registered" in lc_DontAllow.
Even if the app is purchased!

Why?

Part of my manifest:

AddManifestText(
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="20"/>
<supports-screens android:largeScreens="true"
<uses-permission android:name="com.android.vending.CHECK_LICENSE"/>
 
Upvote 0

Phsoftware_app

Member
Licensed User
Longtime User
i use this :

B4X:
Sub Checklic

  Dim lc As LicenseChecker
  Dim Pho As Phone
  lc.Initialize("lc", Pho.GetSettings("android_id"), publicKey, "RFhWZxbaWdp".GetBytes("UTF8"))
  lc.SetVariableAndValue("test_1", secret_1)
  lc.CheckAccess
  
End Sub

Sub Activity_Create(FirstTime As Boolean)

  If FirstTime Then
  Checklic
   Else
  --> continue the program
   End If
  
End Sub

Sub lc_Allow
   If test_1 <> secret_1 Then
  '-->not licensed
   Else
   'licensed
   End If
End Sub

Sub lc_DontAllow
  '-->not licensed
End Sub

Sub lc_Error (ErrorCode As String)
   '-->not licensed
End Sub
is correct?
 
Last edited:
Upvote 0

Phsoftware_app

Member
Licensed User
Longtime User
Sorry for the code,just update..

is this correct?

B4X:
Sub Process_Globals

  Dim publicKey As String
  publicKey = "MIIBIjAN......."
  Dim genn_1 As String ' need test_1 or i can change ?
  Dim secret1 As String
  secret1 = "Nu9QwzKy"

End Sub

Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
  Checklicense
Else
  ' start program --> license accepted
End If
End Sub

Sub Activity_Resume

   Checklicense ' <--- need here too or not?

End Sub

Sub Checklicense

  Dim lc As LicenseChecker
  Dim Pho As Phone
  lc.Initialize("lc", Pho.GetSettings("android_id"), publicKey, "testapp".GetBytes("UTF8"))
  lc.SetVariableAndValue("genn_1", secret1)
  lc.CheckAccess

End Sub

Sub lc_Allow

  If test_1 <> secret_1 Then ' <---- need here too or not?
   lcok
  else
   exapp
  end if

End Sub

Sub lc_DontAllow
exapp
End Sub

Sub lc_Error (ErrorCode As String)
exapp
End Sub

Sub lcok

  genn_1 = secret1 ' <--- need or not?
  ' continue app (licensed)

End Sub

Sub button1_click ' test

If genn_1 <> secret1 Then
exapp
Else
' continue app (licensed)
End If

End Sub

Sub button2_click  ' test

If genn_1 <> secret1 Then
exapp
Else
' continue app (licensed)
End If

End Sub

Sub exapp

  ExitApplication

End Sub

is this correct?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0
Top