Hi Udg i tried your Lib with the 1.26 example script but now i get this strange error
java.lang.NoClassDefFoundError: anywheresoftware.b4a.http.HttpClientWrapper
at anywheresoftware.b4a.samples.httputils2.httputils2service._process_globals(httputils2service.java:137)
at b4a.example.appupdate.main.initializeProcessGlobals(main.java:317)
at b4a.example.appupdate.main.afterFirstLayout(main.java:96)
at b4a.example.appupdate.main.access$100(main.java:17)
at b4a.example.appupdate.main$WaitForLayout.run(main.java:78)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:788)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:604)
at dalvik.system.NativeStart.main(Native Method)
This is the code from your zip with my apk and info file just to test out
#Region Project Attributes
#ApplicationLabel: AppUpdating Example
#VersionCode: 1
#VersionName: 1.01
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim apkupdt As cl_appupdate
Private EditText1 As EditText
Private btnCurVer As Button
Private btnPackage As Button
Private btnWebVer As Button
Private btnCompare As Button
Private btnDwnld As Button
Private btnInstall As Button
Private ButtonUpdate As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("Layout1")
EditText1.Color=Colors.White
EditText1.TextColor=Colors.Black
EditText1.Text="Step by Step library usage"&CRLF
If FirstTime Then
apkupdt.Initialize(Me,"update")
apkupdt.Verbose = True 'this one affects the verbosity of the logs
End If
'ALWAYS NEEDED - this is yor app's package name (see "Project/Package name")
apkupdt.PackageName = "b4a.example.appupdate"
'ALWAYS NEEDED - this is the complete path to the text file holding the newer version number
apkupdt.NewVerTxt = "https://archive.org/download/kraakie_gmail_Test/version.info"
'ALWAYS NEEDED - this is the complete path to your newer apk
apkupdt.NewVerApk = "https://archive.org/download/kraakie_gmail_Test/C64.apk"
'OPTIONAL - Set credentials to access a protected folder. Not needed for this example
apkupdt.setCredentials("test","test")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
'STEP 0: which is apk's package name?
'Can be called at any time not necessarily as step 0 as shown here
Sub btnPackage_Click
'Show package name
EditText1.Text=EditText1.Text&"Package name: " & apkupdt.PackageName&CRLF
End Sub
'STEP 1: which is apk's current version number?
'Can be called at any time not necessarily as step 1 as shown here
Sub btnCurVer_Click
'Read version number of currently executing apk
apkupdt.ReadCurVN 'send out command; async result in update_UpdateComplete
End Sub
'STEP 2: Just curious about eventual availability of a newer apk version, so we simply check for it
'Can be called at any time not necessarily as step 2 as shown here
Sub btnWebVer_Click
'Read version number as showed in txt file on webserver
apkupdt.ReadWebVN 'send out command; async result in update_UpdateComplete
End Sub
'STEP 3: Must follows steps 1 and 2. Assuming no errors in steps 1 and 2
Sub btnCompare_Click
If apkupdt.CurVN < apkupdt.WebVN Then
EditText1.Text=EditText1.Text&"Newer version available"&CRLF
Else
EditText1.Text=EditText1.Text&"No newer version available"&CRLF
End If
End Sub
'STEP 4: let's download the apk published on the webserver. No check on its version, just download it
'Can be called at any time not necessarily as step 4 as shown here
Sub btnDwnld_Click
'download apk from webserver raising appropriate errors when problems arise
apkupdt.DownloadApk 'send out command; async result in update_UpdateComplete
End Sub
'STEP 5: Must follow step 4. Let's ask the user to install the just downloaded apk's newer version
Sub btnInstall_Click
apkupdt.InstallApk 'send out command; async result in update_UpdateComplete
End Sub
'Do it all (steps 1 to 5) with a single call
Sub ButtonUpdate_Click
EditText1.Text="A single sub call does it all"&CRLF
'OPTIONAL - if you like to show a splash screen while checking for a newer apk goes on
apkupdt.SetAndStartSplashScreen(Activity,LoadBitmap(File.DirAssets, "updating.jpg"))
'NEEDED - this is the one you need if you want to perform "automatic" updating of your apk
apkupdt.UpdateApk 'checks for newer apk, downloads it and asks the user to install it
End Sub
'This subs gets called after each command is executed
Sub update_UpdateComplete
apkupdt.StopSplashScreen
'too lazy to manage error conditions..check apkupdt.ERR_xxx codes if you like
Select apkupdt.Status
Case apkupdt.OK_CURVER
EditText1.Text=EditText1.Text&"Running apk version: " & apkupdt.CurVN&CRLF
Case apkupdt.OK_WEBVER
EditText1.Text=EditText1.Text&"Webserver apk version: " & apkupdt.WebVN&CRLF
EditText1.Text=EditText1.Text&"Optional Change Log data: " & apkupdt.WebChangeLog&CRLF
Case apkupdt.OK_NEWERAPK
EditText1.Text=EditText1.Text&"Newer version available"&CRLF
Case apkupdt.NO_NEWERAPK
EditText1.Text=EditText1.Text&"No newer version available"&CRLF
Case apkupdt.OK_DOWNLOAD
EditText1.Text=EditText1.Text&"Newer version downloaded"&CRLF
Case apkupdt.OK_INSTALL
EditText1.Text=EditText1.Text&"User asked to install newer version"&CRLF
Case Else
EditText1.Text=EditText1.Text&"Status: "&apkupdt.Status&CRLF
End Select
End Sub