Automatic App updates?

techknight

Well-Known Member
Licensed User
Longtime User
Is there a way for your app to connect to a server, check for an update, and once found, prompt you to download/install the update?

Reason I ask is my app is not going to be on the market, and will operate outside of the market, So that being said I need a way to check for updates/download updates outside of the google market.

any way to do this? Thanks. I am going to have my own webserver that the apps are hosted on. And i have control of the php/mysql/www of that server space.
 

susu

Well-Known Member
Licensed User
Longtime User
My solution is:
- Place a text file name "version.txt" on my host. Its content is the number of new version, for example: 2.
- My app have a variable name "currentversion" = 1.
- When my app starts, it reads content of file "version.txt" into "newversion" variable, if newversion > currentversion, my app will prompt there's new update then users can choose to update by downloading from my host or Google Play.
- In new version of your app, just change "currentversion" = 2.
- That's all :D
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
Yea, I thought about that as I used to do the very same thing in VB6. But I had a backgrounder app that would launch and the main app would kill the current VB6 process, open an inet control and download the app into a temp folder and reinstall. Then the backgrounder app would close and open the main app.

But the concern I have, is I dont think you have that much "freedom" in android unless it was rooted. So i would almost need a service that downloads the APK from the server, and requests the install. So the user clicks the install button as normal in android, and the main app closes, install, and reopens the app.

Same thing B4A bridge does I guess.

But in the case of android, i could use the httputils control to fetch the version.txt?
 
Last edited:
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
I did have a look at the B4A Bridge source, which does the very same thing killing and relaunching/installing apps.

But not exactly how to parse the Buffer() variable to be able to repurpose those routines.
 
Upvote 0

susu

Well-Known Member
Licensed User
Longtime User
- I used HttpRequest to fetch content of version.txt
- When user press on "Download" button my app will start an intent to open browser then it will download the apk file. This way the browser will take care the downloading but users need to install the apk file manually. I used this code:

B4X:
Dim newintent As Intent, uri As String
uri="http://www.mywebsite.com/myapp.apk"
newintent.Initialize(newintent.ACTION_VIEW,uri)
StartActivity(newintent)

- Another way is you use HttpUtils to download apk file and install it automatically by using this code:
B4X:
Dim i As Intent 
i.Initialize(i.ACTION_VIEW, "file:///sdcard/myapp.apk")
i.SetType("application/vnd.android.package-archive")
StartActivity(i)
*Package Manager will kill your app if it's running.
 
Last edited:
Upvote 0

padvou

Active Member
Licensed User
Longtime User
Works fine,
however after downloading the apk, it gives me the "Error analyzing package" message.
Any ideas?

- I used HttpRequest to fetch content of version.txt
- When user press on "Download" button my app will start an intent to open browser then it will download the apk file. This way the browser will take care the downloading but users need to install the apk file manually. I used this code:

B4X:
Dim newintent As Intent, uri As String
uri="http://www.mywebsite.com/myapp.apk"
newintent.Initialize(newintent.ACTION_VIEW,uri)
StartActivity(newintent)

- Another way is you use HttpUtils to download apk file and install it automatically by using this code:
B4X:
Dim i As Intent 
i.Initialize(i.ACTION_VIEW, "file:///sdcard/myapp.apk")
i.SetType("application/vnd.android.package-archive")
StartActivity(i)
*Package Manager will kill your app if it's running.
 
Upvote 0
Top