B4A Library AppUpdating - automate apps updating from a webserver

Status
Not open for further replies.

udg

Expert
Licensed User
Hi Steve,

looking at the log you posted above I can see that both package name (b4a.CustomerTablet) and text file should be correct since the lib finds your newer release number (1.01 against its previous 1.00).
What is missing is the newer apk file.
I suspect the problem being the capitalization in CustomerTablet.apk since I had a similar problem time ago.
Please verify whether the name on the webserver is exactly the same as that put in NewVerApk variable.

Regards,

Umberto
 

DonManfred

Expert
Licensed User
Please verify whether the name on the webserver is exactly the same as that put in NewVerApk variable.
As additional info to @Steve Miller :

The urlpath AND apkfilename is CaseSensitive and should exactly mirror the structure and filename on your webserver...
 

Steve Miller

Active Member
Licensed User
Since I can't place the project up here, here are the important parts:

Package Name:
B4X:
b4a.CustomerTablet
Manifest:
B4X:
AddReceiverText(eu.dgconsulting.appupdating.newinst2,
  <intent-filter>
  <action android:name="android.intent.action.PACKAGE_REPLACED" />
    <data android:scheme="package" />
  </intent-filter>)
Versioning in project:
B4X:
#FullScreen: False
    #IncludeTitle: True
    #ApplicationLabel: CustomerTablet
    #VersionCode: 1
    #VersionName: 1.00
    #SupportedOrientations: Landscape
    #CanInstallToExternalStorage: True
Subroutine for checking:
B4X:
Sub CheckForUpdates
      apkupdt.Initialize(Me,"UpdateCheck")                
    'this is yor app's package name (see "Project/Package name")
    apkupdt.PackageName = "b4a.CustomerTablet"
    'this is the complete path to the text file holding the newer version number
    apkupdt.NewVerTxt = "http://www.xxxx.us/CustomerTablet/version.txt"
    'this is the complete path to your newer apk
    apkupdt.NewVerApk = "http://www.xxxx.us/CustomerTablet/CustomerTablet.apk"
    'apkupdt.UserName = "CustomerTablet"        'needed since folder p_apk has access restrictions
    'apkupdt.UserPassword = "suncoast"    'as above
    'this function starts checking for any newer version of the current app
    apkupdt.LookForNewVersion                                                    

End Sub
Sub UpdateCheck_UpdateComplete
  Log("Status: "  & apkupdt.Status)
  If apkupdt.IsDone Then
    Log("New Ver available: " & apkupdt.NewVerAvailable)
    Log("Status: "  & apkupdt.Status)
    apkupdt.StopSplashScreen
    If apkupdt.Status = 6 Then
      Log(apkupdt.PackageName)
    End If
  End If
End Sub
Also, when the package compiles, it is called CustomerTablet.apk.
 

Steve Miller

Active Member
Licensed User
I have the CustomerTablet as a virtual folder on the site and it finds the version file just fine. The apk is in the same folder and named just as it is shown.
 

DonManfred

Expert
Licensed User
Umberto and i are working on a new version of this library (the lib is umbertos part)... He´s actually in holiday but maybe tomorrow he will be back at his pc and have a deeper look into this problem.

There will be a windows-tool available in future (that´s my part) which will upload the right files to the right place on your webserver

snap0005.png
 

udg

Expert
Licensed User
Hi Steve,

unfortunately I'm away from my PC so I can't check the lib code.

I have a second question for you: when you copy the string

http://www.xxxx.us/CustomerTablet/CustomerTablet.apk (xxxx appropriately substituted by its real counterpart)

in your browser url box, does the apk's download start?

If not, does it start when the whole string is lower-cased?

I saw you commented out the credentials so I derive that currently the folder is not protected, right?

Umberto
 

Steve Miller

Active Member
Licensed User
Nice!
I'm looking at the AppUpdating source from the top of this thread, to see if I notice anything that may be interfering with my calls.
 

Steve Miller

Active Member
Licensed User
Interestingly enough, I get a not found from the browser also...Hmmmm. Strange how it finds the version.txt, but not this. Good point!
Something for me to look into further.
 

Steve Miller

Active Member
Licensed User
No, I had to add it as a mime type in IIS. It was IIS that was causing the not found issue because it didn't recognize the file type.
 

Steve Miller

Active Member
Licensed User
I have a question. My app uses the kiosk mode and the automatic updating. I'm finding that when an update is found, the notification gets pushed to the background behind my app, due to the kiosk mode. It happens so
Fast that I don't see the notification to install the updated app. The kiosk mode doesn't allow me to close the app in order to reply to the install prompt. My app simply opens again, over the install prompt.

Is there any way to have the install go automatically without being prompted or have the prompt be modal over my kiosk app?
 

udg

Expert
Licensed User
Hi Steve,

unfortunately a completely automatic (and silent) install/update is forbidden in Android (as far as I know).
User intervention is always needed.

The good news is that you could insert a few lines of code in function JobDone in order to open a confirmation dialog box just before the sending of the intent. That is between status=5 and status=6.
So, if the user response is negative you just skip the intent stuff otherwise you execute those lines (but this will result in the user prompted again, this time by the OS).

On a second thought, maybe I could release a newer AppUpdating version where a boolean discriminate bewtween going straight to the sending of OS intent and stopping at status=5 (newer apk downloaded), leaving control on how to proceed to your Main.
What do you think?

Umberto
 

Steve Miller

Active Member
Licensed User
Hi Umberto,
I need to somehow get the install prompt to not fall behind the app. When the app is in kiosk mode, it is always in the forefront. And if it is closed, it always restarts and is in forefront again. Taking that all out of kiosk mode if an update is available may work, but I need to be sure that once the install is done or cancelled, my app is started again. I don't know how to code this, or if it is even possible.
 

udg

Expert
Licensed User
Hi Steve,

maybe one way to solve this situation could be to use AppUpdating just to discover an eventual newer apk version and then download it. All this in kiosk mode.
When your app (or a launcher app) is started again, this time NOT in kiosk mode, it will look for the already downloaded update version and send the OS intent. This way if the user accepts the installation you end up with the update app ready to start (now in kiosk mode); otherwise you manage how to proceed (kiosk mode+old version OR message like "service unavailable until you upgrade.." OR anything you think it may fit).

Let me know if this is may fit your needs and I will upgrade AppUpdating accordingly.

Umberto
 

Steve Miller

Active Member
Licensed User
I need to think of how to best handle this. The problem is this app is for a doctors office. Its a registration app that the patients use to sign in or register as a new patient. So, the tablet needs to be locked down at all times, that's the reason for kiosk mode. I can't take the chance of it being out of kiosk mode while in the hand of a patient.
 
Status
Not open for further replies.
Top