B4A Library AppUpdating - automate apps updating from a webserver

Status
Not open for further replies.

udg

Expert
Licensed User
Hi Douglas,

as Manfred pointed out with his question, eu.dgconsulting.appupdating can't be your package name since its it the library's package name.
The code you add to the Manifest simply ask the OS to awake AppUpdating library (as part of your app) when any package is updated on the device. Then is the library responsability to filter just the app it's linked to, so the importance of the real package name as set in Project/Package name.

Umberto
 

udg

Expert
Licensed User
@Douglas Farias:
Have a look to post #7 through post #10 .. it should be your case.
 
Last edited:

udg

Expert
Licensed User
AppUpdating version 1.26 released today!

Attached to post #1 you may find two new zip files:
- AppUdating_126: updated library fles; just copy to your extralib dir and you're ready
- AppUpdating_126_ex: example app (with source) showing lib usage

ChangeLog for version 1.26
  • added property WebChangeLog to read optional app's version changelog data
  • better management of versioning in the info file
This update introduces a more informative structure for the info file although it preserves full compatibility with previous versions.

Until version 1.25 we were limited to a single line info text file in the form of
B4X:
ver=x.yz
Version 1.26 recognizes that same format along with the richer one:
B4X:
version=x.yz
<ChangeLog>
any number of text lines
describing features for
your newer version x.yz
</ChangeLog>
Simply put, if you want to append extra info describing your newer apk, just do it between the above mentioned tags.
About the version number; it's no more restricted to start on the fifth info file character as in previous versions, but it should be placed soon after an equal sign (running then to the optional ChangeLog tag or to the end of file).
So acceptable formats are now:
ver=1.21
version =1.21
my fantastic app - version=1.21
my fantastic app
version=1.21

There is no check about what follows the equal sign since you may decide to use any string as your version number (i.e "abc" is ok as it is "1.32").

Umberto
 
Last edited:

incendio

Well-Known Member
Licensed User
Hi,

I don't have a web server. Can I use this library to download updated app from dropbox?
 

udg

Expert
Licensed User
Hi,
I never test it with any different source than a webserver, but it could work.
If you read the provided source code, you can find that it uses httputils2' download method to read in both the text file and the newer apk, so as long that one works with Dropbox so should AppUpdating.

Umberto
 

incendio

Well-Known Member
Licensed User
Hi,

Tested with dropbox, failed, with error, something like connection refused.
Your source code included user name and password, I skip this part cause it is a dropbox shared link that does not required password.

I guess, I know why it failed. Dropbox shared link need users to press download button.
 
Last edited:

udg

Expert
Licensed User
Hi,
unfortunately I'll be away from my dev PC for a whole week, so I won't be able to test it myself.
Can you use Erel's DropBox Sync lib to manage access to your shared folder on DropBox and then copy&paste from my code the bits of code needed to issue the intent command for installation?
A lot of work, but all you need is almost there..

Sorry to not be able to better help you "on the fly"

Umberto
 

incendio

Well-Known Member
Licensed User
Hi Umberto,

Thanks for your concern. Don't worry about this.

I am still considering between using Erel's DropBox or build a web server then use your library on this web server.
 

incendio

Well-Known Member
Licensed User
Hi Umberto,

I manage to use your library on dropbox without any modification.

Thanks for your work and glad that no need web server for this :)

In case someone needed, change drop box share link with this tips :
http://www.basic4ppc.com/android/forum/threads/dropbox-direct-link-to-download-files.45564/

Just to make sure, I use Http2Service in my app, your library also use this, do you use standard Http2Service without any modification? I tried Erel's modified version of Http2Service and my app doesn't work correctly.
 

udg

Expert
Licensed User
Hi incendio,

I'm glad to hear the lib worked for you!
I confirm that I used HttpUtils2 in its standard form, no modifications at all.

Thanks for the tip about Dropbox.

Umberto
 

incendio

Well-Known Member
Licensed User
Hi Umberto,

I got a strange behavior running example from the latest version.

Just run your example, press Get Current version button, then press back button to quit app.
Immediately, run again your example, press again Get current version button, this time it will return empty/nothing.
 

udg

Expert
Licensed User
Let me find an available PC where to download the example program in order to have a look at it with an editor since I am away from my dev machine.
I guess it has something to do with some code misplaced in the "firsttime" section of create sub (relative to the example program)..more when I know more.

Edit: ok, found a suitable PC and read the code.
I'm not sure 100% since I can't test the code, but it seems that placing the Dimmming of var apkupdt in sub Globals may cause the problem that manifests itself when you close the demo app and, soon after that, you launch it again.
What happens is that the FirstTime boolean returns False in a situation like this one, so apkupdt has no chance to initialize the package name, which is used to query the current version number.
In EditText1 you should read an error code (Status: -1, i.e. ERR_NOPKG).

1. To solve the problem at hand, just move the Dim apkupdt line to sub Process_Globals
2. To understand it, read the App lifecycle tutorial. To summarize the latter here, when you exit the app you are closing its only activity BUT the process to which the app belongs to will remain in memory as long as the OS doesn't need to recover some memory space. So, when you start the app again, the process is still there (which applies to any process_globals variable too) and FirstTime returns False because this isn't the first time the process is run.
Since my demo initializes apkupdt properties in Activity_Create only when FirstTime returns True that causes the "strange" bahavior you experienced.

To say it just in a couple of words, the uploaded demo simply proves my poor programming!

Umberto
 
Last edited:

incendio

Well-Known Member
Licensed User
I can confirmed that if your app still active in memory after user closed it, Get Current version will return nothing. But if it is completely removed after user quits, it runs correctly.

To say it just in a couple of words, the uploaded demo simply proves my poor programming!
Don't be to hard on your self, :)... we all still learning.
 

aidymp

Active Member
Licensed User
Hi, my app is basically written around the Largefileexample its now well established and quite large! I have tried to add this very useful library and code to my app. I have the server setup, i have all the code written and seemingly correct, i have removed the module httputils2 and it compiles and runs, however it will not down load anything, so getwebver (sorry im in bed and typing on my phone, so know the commands and not exactly correct) i get a log message like job submitted to uninitialized service. And i never get the webver to actually download, similarly my apps normal download feature is now also broken. I understand that there is a conflict somewhere. The question I have is, can the appupdating library AND the b4a example project largefiledownloader work together? As i have tried several times and for quite a few hours this evening... Any help appreciated
 

udg

Expert
Licensed User
Hi,
are your using this example? If yes, it advices not to use the http2 library but the provided class since it needs a special version of the former.
AppUpdating uses the standard http2 library, so I guess the only way to have both is to merge the two; I mean making a library from the http2 special version needed for the largedownload and then compiling AppUpdating against that new library instead of the standard one.
Let me know if you incurr any difficulties and eventually like my help.
 
Last edited:

aidymp

Active Member
Licensed User
Hi,
are your using this example? If yes, it advices not to use the http2 library but the provided class since it needs a special version of the former.
AppUpdating uses the standard http2 library, so I guess the only way to have both is to merge the two; I mean making a library from the http2 special version needed for the largedownload and then compiling AppUpdating againt that new library instead of the standard one.
Let me know if you incurr any difficulties and eventually like my help.
Hi udg, Thank you for your reply. YES that is the example I am using, it is now deeply embedded in my app, Thus I cannot really do much about the it in the app.

I will look at the source again for both the Largefiledownload example and Appupdating.

I dont know anything about making librarys and was hoping that say renaming the subs & module names in largefiledownload example may make it work? as that only references the HTTP library! Do you think that could be possible??

Thank you

Aidy
 

udg

Expert
Licensed User
Let me have a look at the LFD code.
With some luck, we just need to recompile AppUpdating as is, but this time using LFD's http2 version instead of the standard one.
Stay tuned... :)
 

aidymp

Active Member
Licensed User
Let me have a look at the LFD code.
With some luck, we just need to recompile AppUpdating as is, but this time using LFD's http2 version instead of the standard one.
Stay tuned... :)
Thank you so much... I have been trying to sort this out since my purchase of B4A (Im not new to basic (I used Spectrum, Amiga (AMOS) Atari ST (STOS)) but I am new to B4A and havent programmed for over 20 years! I am so impressed with B4A and the community!

I am not using Playstore so the Auto update feature is very important to me! If you can help at all I will be very happy to donate! ;)

Staying Tuned! ;)

Aidy
 

udg

Expert
Licensed User
Edit: removed attached file since it proved not working as hoped :(

Hi Aidy,

try to compile your program with the library attached to this same post.
You should first eliminate from your code any copy of modules HttpJob, HttpUtils2Service and DownloadService since I needed to enclose them in this version of AppUpdating (version 1.27LFD).
Obviously, if you altered those modules from what's attached to Erel's example I need to use your modified copies instead of the ones used. Let me know.

udg
 
Last edited:
Status
Not open for further replies.
Top