Note: since AppUpdating is still in its infancy and I don't feel it's ready to migrate to the contribued libraries section of the forum, I'll keep publish here newer versions of it, keeping at the same time older ones because of inconsistencies between versions.
Sorry for any inconvenience.
Hi all,
when they say B4A is a RAD definitely they underestimate its power!
Reading only a few threads and looking at a single example code I could retool my AppUpdating lib using classes, adding a splash screen and even a call back function. Can't believe it took less than a day! I'm really impressed.
So, please, find attached version 1.02 of AppUpdating. It is still a work in progress so please don't rely on it for production code. Feel free to suggest improvements, hints and obviously let me know about errors (or should i say horrors? eh eh).
That said, since version 1.02 is so much different from its previous attempt, I believe you may find it useful if I publish my actual code for calling and managing the lib. Here it is:
Sub Globals
..
Dim apkupdt As AppUpdating
End Sub
Sub Activity_Create(FirstTime As Boolean)
...
Activity.LoadLayout("Main")
...
If FirstTime Then
apkupdt.Initialize(Me,"testlib")
apkupdt.PackageName = "eu.dgconsulting.tmb"
apkupdt.NewVerTxt = "http://www.dgconsulting.eu/sites/default/files/apk/tmb.txt"
apkupdt.NewVerApk = "http://www.dgconsulting.eu/sites/default/files/apk/TMB.apk"
apkupdt.SetAndStartSplashScreen(Activity,LoadBitmap(File.DirAssets, "tmb0.png")) 'this one is optional
apkupdt.LookForNewVersion
End If
End Sub
Sub testlib_StopSplashScreen
If apkupdt.IsDone Then
Log("A new version is available: " & apkupdt.NewVerAvailable)
Log("Asked user to update apk: " & apkupdt.AppUpdated)
apkupdt.StopSplashScreen
End If
End Sub
If you decide to use a splash screen just note that it gets superimposed on your main layout (it's made up of a panel and the bitmap you pass as the second parameter on function SetAndStartSplashScreen). In the call back function testlib_StopSplashScreen (I've to decide for a better name..) than you simply call apkupdt.StopSplashScreen and the splash screen is removed.
Otherwise simply comment out both SetAndStartSplashScreen and apkupdt.StopSplashScreen.
Property apkupdt.NewVerAvailable simply tells you an upgrade exists for you apk
Property apkupdt.AppUpdated, when True means the newer apk was downloaded and the intent for its installation was called (but we don't know if the user applied the change).
There's a lot more work to be done before I dare to publish this lib in the contributed libraries forum, but now I feel I'm on the right track..
Umberto