B4A Library AppUpdating - automate apps updating from a webserver

Status
Not open for further replies.
Important note: since all the changes made to the Android OS the original code is to be considered outdated. Thanks to @Yayou49 you may find at post#290 a version of the class usable on Android 6+ versions.

Note: version 1.25 breaks existing code so, please, read changelog in post #60 below.


Hi all,

this is my first contributing lib to this great NG.
How do I dare to publish such a low-grade stuff in an area where generally you may find real masterpieces of programming? Well, to be honest, I hope in your help to upgrade my work to a status of "ready-made solution" for those who prefer to run their own webservers where to publish apps.
Secondly, I was asked (both privately and publicly) to overcome my legitimate embarassment and go on with the publication. So, here we are: AppUpdating 1.18!

Note: any valid code fragment comes from some other thread, while all the bad stuff is entirely mine ;-)

Please find attached both the library as is (yes, it works out of the box) and its source code.

On a following post I'm gonna describe the lib in greater detail and show how to use it.

Umberto

AppUpdating version history

* version 1.30 (read notes on post #228)
  • compiled with okHttp 1.01 and okHttpUtils 2.20
  • removed files for version 1.25

* version 1.26 (read notes on post #84)
  • added property WebChangeLog to read optional app's version changelog data
  • better management of versioning in the info file
  • removed files for version 1.18 to avoid confusion (still available on request)
* version 1.25
* version 1.18
  • initial release
 

Attachments

  • AppUpdating_126_ex.zip
    28.3 KB · Views: 943
  • AppUpdating_126.zip
    11.3 KB · Views: 989
  • AppUpdating_126_src.zip
    10.8 KB · Views: 757
  • AppUpdating_130.zip
    11.4 KB · Views: 936
  • AppUpdating_130_src.zip
    15.7 KB · Views: 859
  • AppUpdating_130_ex.zip
    33.4 KB · Views: 1,035
Last edited:

udg

Expert
Licensed User
Longtime User
I see.
What if the whole updating stuff is run only on device boot followed by entering the kiosk mode and app launching?
 

udg

Expert
Licensed User
Longtime User
As Manfred told you a few posts above, we're working on a new project.
The lib part of it will be something closer to the service active in Google's PlayStore: something that from device boot looks for eventual upgrades of listed apps and then sends notifications letting the user to decide what and when to upgrade/install.

Maybe to solve your problem you don't need the whole stuff, but just a few pieces to re-assemble at your will.

I see a scheme like:
1. Device boot
2. "Special" app launches itself and discovers apps to be updated (in your case, no notification is needed)
3. for each app which has a newer version the "special" app downloads the apk and sends the appropriate OS Intent
4. the user (medical staff or anyone working at that office) accepts or denies updates
5. on "special" app termination you set the Kiosk Mode and launch the app with which the patients operate

Could this work for you?

Umberto
 

Theera

Well-Known Member
Licensed User
Longtime User
Hi DonManfred,or all
I've interested this thread for a long time,I've just found how to set my own web server as localhost.
I have 2 problems to ask you.

1.) I use phpThai as webserver alike xampp,I've done,but I can't set the tablet link to the web server(I use win8 32 bits as web server) How to set my windows8 for this connection?
2.) In your post11 ,I get your example,inside of txt file (it means as the attached picture ) ,Should I write something in it?
 

Attachments

  • MyWebServerPic.png
    MyWebServerPic.png
    5.1 KB · Views: 170
Last edited:

Theera

Well-Known Member
Licensed User
Longtime User
Hi again,
The lastest,I have tried,I 've error.
 

Attachments

  • MyStepSetting.png
    MyStepSetting.png
    73.7 KB · Views: 167
  • MyError.png
    MyError.png
    5.1 KB · Views: 157
  • MyProperties.png
    MyProperties.png
    11.9 KB · Views: 152

DonManfred

Expert
Licensed User
Longtime User
You dont need to change your network-card-settings! At the time you can see something like on your MyWebServerPic.jpg you are ready

The process of the webserver (phpthai?) should have access to internet through your firewall... But if it has access then you should be able to call your phprhai from your app

You want to use YOUR PC as server, yes?
look what Internet-IP you have... For example if your internet-ip is 123.12.34.45
then the adress to apk in your app should look like http://123.12.34.45/b4a/apk/TestAnchor.apk

BUT. The most people dont have an static (not changing) IP-Address.. So, this ip could have an other value when you restart your computer...
In that case you app can not reach your computer cause of ip-address changes... Maybe your computer now have
123.12.34.92 as ip and your app dont know this adress. So it runs into a not found error...
The new apk-url is http://123.12.34.92/b4a/apk/TestAnchor.apk now

Best way is to have an small webhosting at some webspace-provider beside a domain... an IP from an domain useually dont change.

You then just upload your txt and apk file to your webspace and then, in your app, you set the path to
http://myowndomain.tld/b4a/apk/TestAnchor.apk
when your registered domainname is "myowndomain.tld"
 

Theera

Well-Known Member
Licensed User
Longtime User
Hi Manfred,
My Ip Adress is 192.168.1.3 as web server,I try to input at the tablet " 192.168.1.3/b4a/apk" ,but It's not work. How do I do?(I'm not expert all of computer,I've many tried to search from google)
My tablet can't connect to my server.
 

Attachments

  • MyIpAddressIs.png
    MyIpAddressIs.png
    10 KB · Views: 141
  • lastestPic.png
    lastestPic.png
    4.6 KB · Views: 134
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Your ip 192.168.1.3 is your LAN(1)-IP-Address.
Your APK should be able to reach this address if your device is in your WIFI.

If the device is using internetconnection NOT YOUR WIFI... e.g. a internetprovider,,, THEN you must use your WAN(2)-IP-Address you got from your internetprovider..

Call the url http://www.wieistmeineip.de/ from your pc... The big IP in the top is your WAN-IP

Use this ip in your app in url...

(1): LAN LocalAreaNetwork (your router, your pc, any device who connects to your router)
(2): WAN WideAreaNetwork (anything else (not in LAN)... THE INTERNET)

In you router (the one under 192.168.1.1) for example you should somewhere see your WAN address... THAT´s the ip you should use in your app
 
Last edited:

Theera

Well-Known Member
Licensed User
Longtime User
Hi Manfred,
I'm sorry ,you quickly answer. If I understand your words,I must use ip address instead of domain name,but I can't do it be connection
 
Last edited:

Theera

Well-Known Member
Licensed User
Longtime User
Thailand is 3.00 pm ,I have stay at computer 08.00a.m.-03.00p.m. ,I always wake up at 04.00a.m. ,I sleep at 09.00-10.00p.m. But I still be stupid.
 

Theera

Well-Known Member
Licensed User
Longtime User
i will try tomorrow,thank you
 

Theera

Well-Known Member
Licensed User
Longtime User
Hi Manfred,
I'm sorry to reponse you so late, I 've tried myself,but it's not worked. Please help me again. :(
 

Attachments

  • MyInfo.png
    MyInfo.png
    10.6 KB · Views: 136

DonManfred

Expert
Licensed User
Longtime User
Have you tried to call http://125.26.84.96/b4a/apk/ from your PCs Webbrowser?
If that work it should work from your app also. If that not work then the problem seems in your firewall and/or antivirus.
Maybe the port 80 is not open from your firewall?
 

Theera

Well-Known Member
Licensed User
Longtime User
Yes,I have done. I think I should search it in the book 's store before and return back again. Thank you Manfred.
 

DonManfred

Expert
Licensed User
Longtime User
If you have an router then the problem could be there.
Look in your routers manual how to configure a portforwarding.

pubic port: 80
local port: 80
ip: 192.168.1.3
type: TCP

Test it with your pcs webbrowser. It must show the same as your localhost/b7a/apk/ call...
 

tuhatinhvn

Active Member
Licensed User
Longtime User
java.lang.StringIndexOutOfBoundsException: String index out of range: 4

error

If FirstTime Then
apkupdt.Initialize(Me,"tab1") 'tab1 has no meaning; use any name you like
'this is yor app's package name (see "Project/Package name")
apkupdt.PackageName = "com.xxx.xx"
'this is the complete path to the text file holding the newer version number
apkupdt.NewVerTxt = "http://xxxx.net/xx/v.txt"
'this is the complete path to your newer apk
apkupdt.NewVerApk = "http://xxxx.net/xx/frmstart.apk"
' apkupdt.UserName = "test" 'needed since folder p_apk has access restrictions
' apkupdt.UserPassword = "test" 'as above
'not needed- just to show use of function GetCurVN
Log("I am version: " & apkupdt.GetCurVN)
'use only if you like to show a splash screen while update checking goes on
' apkupdt.SetAndStartSplashScreen(Activity,LoadBitmap(File.DirAssets, "pioneer-music-wallpapers.jpg"))
'this function starts checking for any newer version of the current app
apkupdt.LookForNewVersion
End If
 

DonManfred

Expert
Licensed User
Longtime User
what´s the content of "http://xxxx.net/xx/v.txt"? For a version of 1.50 it must be


BTW: In the code you posted i cannot see anything what could give an StringIndexOutOfBoundsException...

Maybe there are more infos in the log about this error? Maybe a line of code where the exception happens
 
Last edited:

udg

Expert
Licensed User
Longtime User
AppUpdating version 1.25 is finally released!

Attached to post #1 you may find three new zip files:
- AppUdating_125.zip: updated lirary fles; just copy to your extralib dir and you're ready
- AppUpdating_125_src.zip: source code to library files
- AppUpdating_125_ex: example app showing lib usage

Unfortunately version 1.25 breaks existing code. Sorry guys.
A few variables are gone and even the main sub changed its name, but now everything appears more coherent to me and easier to maintain.

ChangeLog
To set credentials to access a protected folder on webserver you now have a new function: setCredentials(Username, Password).
Properties sUserName and sUPassword are no longer directly reachable.
NewVerAvailable var is no longer available
IsDone function is no longer available
LookForNewerVersion function changed its name to UpdateApk
Added costants for Error codes and Status codes
Added property sVerbose; setting it to TRUE makes logs mode veeery verbose
Previous sub GetCurVN is now ReadCurVN
Added newer and different function getCurVN to be coherent with getWebVN
Now you're expected to call the Readxxx functions first and on their completion call the getXXX counterparts.
Added step-by-step function: ReadCurVN, ReadWebVN, DownloadApk, InstallApk
So now you could call UpdateApk which does all the work in a single rush or call each of the above functions to retain more control over the process.

You are encouraged to have a look at the example code where any feature is used.

Once again, sorry for any inconvenience this update may cause to you.

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