B4A Library AppUpdating (dl.dropbox.com)

'Author: @UDG
'Last Modified: 07.08.2016
'Location: Di Gioia Consulting - Lugano (CH)
(Strong thanks to the authors for the released version of libraries on the Forum.)

AppUpdate v1.02 [post]
AppUpdate works with dropbox. You can always use dropbox to host your APK files and TXT files.
the URL for that is dl.dropbox.com instead of www.dropbox.com

A little modified for own needs library (author: UGD), which allows for direct
downloading files from the internet to your phone from the shared DropBox folder (https://dl.dropbox.com)
- see: AppUpdating_testing.zip

B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    '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 AppUpdate

End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
 
    '**************************************************************************************************************** EXAMPLE -1- *****************
    'EXAMPLE -1-
    'Download myapp.apk file from webserver
    If apkupdt.Initialize(Me,"tab1") Then 'tab1 has no meaning; use any name you like
        'this is the complete path to your newer apk
        apkupdt.setNewVerApk("https://dl.dropbox.com/s/u5dsjl4a550bjv8/Tesseract.apk?dl=0", "Tesseract.apk")
        apkupdt.SetAndStartSplashScreen(Activity)
        apkupdt.DownloadApk
        apkupdt.StopSplashScreen
    End If
    If Msgbox2("Download Complete", "EXAMPLE -1-", "Next","","Exit",  Null) = DialogResponse.NEGATIVE Then ExitApplication
    '**************************************************************************************************************** EXAMPLE -2- *****************
    '**************************************************************************************************************** EXAMPLE -3- *****************
    'EXAMPLE -3-
    'Download and install myapp.apk file from webserver
    If apkupdt.Initialize(Me,"tab1") Then 'tab1 has no meaning; use any name you like
        'Sets package name for this app. It should equal the value in menu "Project.Package Name"
        apkupdt.setPackageName("b4a.example.sampleOCR")
        'this is the complete path to your newer apk
        apkupdt.setNewVerApk("https://dl.dropbox.com/s/u5dsjl4a550bjv8/Tesseract.apk?dl=0", "Tesseract.apk")
        'Reads current version number from running copy of apk (see #VersionName).
        apkupdt.ReadCurVN
        'super imposed splash screen
        apkupdt.SetAndStartSplashScreen(Activity)
        'Downloads newer apk and asks user to install it
        apkupdt.JobWebVNcompare
        'Stops and removes the super imposed splash screen
        apkupdt.StopSplashScreen
    End If
    apkupdt.Finish(apkupdt.pv.sStatusCode)
    Msgbox2("Download Complete", "EXAMPLE -3-", "OK","","",  Null)
    ExitApplication
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub tab1_LookForNewVersion(action As Int)
    Select action
      Case apkupdt.sc.OK_INIT
          ToastMessageShow("Action OK", True)
      Case apkupdt.sc.ERR_NOPKG
          ToastMessageShow("Missing package name for current version check", True)
      Case apkupdt.sc.OK_CURVER
          ToastMessageShow("Got current version from Project Attributes", True)
      Case apkupdt.sc.ERR_NOTXT
          ToastMessageShow("Missing txt file full path indication", True)
      Case apkupdt.sc.ERR_NOAPK
          ToastMessageShow("Missing apk file full path indication or missing name for App", True)
      Case apkupdt.sc.OK_INSTALL
          ToastMessageShow("User asked to install newer apk", True)
      Case apkupdt.sc.ERR_NOPKG
          ToastMessageShow("Missing package name for current version check", True)
      Case apkupdt.sc.OK_DOWNLOAD
          ToastMessageShow("New apk version downloaded and ready to install", True)
      Case apkupdt.sc.ERR_TXTROW
          ToastMessageShow("Info must be placed between <ChangeLog> and </ChangeLog> markers", True)
      Case apkupdt.sc.OK_WEBVER
          ToastMessageShow("Read apk's version number as published on webserver", True)
      Case apkupdt.sc.OK_NEWERAPK
          ToastMessageShow("Newer apk version available on webserver", True)
      Case apkupdt.sc.NO_NEWERAPK
          ToastMessageShow("Newer apk version no available on webserver", True)
      Case Else
    End Select
End Sub


The modified library works fine on an older version of Android 4.3

Sorry for my bad English :(
Regards.
 

Attachments

  • AppUpdate v1.02.zip
    267.9 KB · Views: 300
  • AppUpdating_testing.zip
    1.5 KB · Views: 295
Last edited:
Top