Hi,
you could adopt the step-by-step scheme showed in the demo. I never used it this way, but it should work.
Something like (untested code, keep just the overall idea):
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
apkupdt.Initialize(Me,"update") 'initializes the class
apkupdt.Verbose = True 'this one affects the verbosity of the logs
End If
'ALWAYS NEEDED - this is your app's package name (see "Project/BuilConfigurations/Package")
apkupdt.PackageName = "b4a.example.appupdate205"
'ALWAYS NEEDED - this is the complete path to the info text file holding the newer version number
apkupdt.NewVerTxt = "http://www.dgconsulting.eu/free_apk/AppUpdateExample2.inf"
'ALWAYS NEEDED - this is the complete path to your newer apk
apkupdt.NewVerApk = "http://www.dgconsulting.eu/free_apk/AppUpdateExample2.apk"
'OPTIONAL - Set credentials to access a protected folder. Not needed for this example
apkupdt.setCredentials("test","test")
'STEP 1: which is apk's current version number?
apkupdt.ReadCurVN 'send out command; async result in update_UpdateComplete
'STEP 2: just curious about eventual availability of a newer apk version, so we simply check for it
apkupdt.ReadWebVN 'send out command; async result in update_UpdateComplete
'STEP 3: compares current version number to the one reported by the webserver
If apkupdt.CurVN < apkupdt.WebVN Then
Activity.LoadLayout("lytUpdate")
'STEP 4: let's download the apk published on the webserver. No check on its version; just download it
apkupdt.DownloadApk 'send out command; async result in update_UpdateComplete
else
Activity.LoadLayout("lytMain")
end if
end sub
'This subs gets called after each command is executed
Sub update_UpdateComplete
LogColor($"UpdateComplete - time: ${DateTime.Time(DateTime.Now)}"$, 0xFF556B2F)
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}"$
EditText1.Text=$"${EditText1.Text}Optional FileSize Log data: ${apkupdt.WebFileSize}${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 apkupdt.ERR_NOPERM
Log("No permission to install")
EditText1.Text=$"${EditText1.Text}User gave no permission to install${CRLF}"$
Case Else
EditText1.Text=$"${EditText1.Text}Status: ${apkupdt.Status}${CRLF}"$
End Select
End Sub
Beware that you have to modify
update_UpdateComplete above since it doesn't manage errorcodes and it makes use of EditText1 which is unavailable until STEP 3 since the layout is not loaded. Keep in mind that loading a layout could take some time so you should make use of Sleep or CallSubDalayed(me, ..).
A better approach could be to set as many resumable subs (in my old demo they're buttons click) as updating steps to go through. Then use
wait for on each.
When time will permit, I will probabily change the lib itself in order to make use of resumables and get rid of UpdateComplete..