We have an Android app (.apk) published to a publicly accessible URL, any user who knows the URL can download and install the app.
The app is already installed on the relevant user phones and allowing sideload option from the settings is turned on.
How can I force the app, on start, to check for update and replace the existing app if found, then restart the app (to pick up the latest version)?
Is there a standard solution or a software package? Should I be thinking in a different way?
I am using Xamarin Forms, however, I am happy with Xamarin Android or any Java-based solution.
One thing you could do is to have a small plain text file in the same server where the APK is, that contains the version number of the APK available on the server. The runing app then just reads that text file and compares against its own version number.
If the version on the server is newer (has a higher version number), you simply download the new APK to a temp dir and install the APK programatically using the method outlined here: Android: install .apk programmatically
The way to go is HockeyApp. It´s a distribution system that does exactly what you are looking for. Besides, you get a useful crash logger and some statistics, etc. It´s free for 2 apps.
Once you install and configure their SDK in your Android app, an activity will popup telling the user a new update is available if there is any.
The user can install the new version with a button tap. Simple.
The setup process involves installing a nuget package and write a few lines of code in your main Activity class.
Related
The device my Android app is running does not have Playstore on it. The plan is to pre-install the software when shipping the device. I am now looking for a strategy to upgrade the application.
I found this useful link to install an Android app from the apk file:
Android: install .apk programmatically
I am thinking I will use this logic to auto-upgrade my app. I am wondering if it is even possible. I am thinking the upgrade will first try to uninstall existing version but will fail as the executable is still running and the file may be locked. Is there a better way? Regards.
Peter, we've just implemented the same thing.
Users have the software pre-installed on their device and we host update APK's on the companies servers.
From the app they can then check for updates where we have a WCF service which extracts the APK file (essentially a .zip) and returns the manifest details. From there we have the version of the APK and can compare it against the local version.
If the user decides to upgrade they can download the APK and you can automatically launch it. At which point the user will be told the application is going to be updated. There are no file locks etc, the app will just close and restart using the new version.
Note: Downgrading is not "automatic". The user would have to first uninstall the app. For upgrades, however, it's a simple case of downloading and launching the APK version (the user will be told they need to allow installations from unknown sources if this is not checked).
You have a couple of options, depending upon your target system.
Use the link you posted. This will provide the user with a traditional install dialog, whereby the user can choose to install or not. You should avoid doing that automatically, as APKs can be large and you might irritate the user if they don't want updates.
You can install updates magically, but you will require the firmware signing key (or possibly root, but I haven't tested that). That will not ask for consent from the user. You will need to add additional code using reflection to access the installation methods of Android. If you go this way, you should build an opt-out/in mechanism.
If your app is open-source, F-Droid would solve the problem for you.
F-Droid is an installable catalogue of FOSS (Free and Open Source
Software) applications for the Android platform. The client makes it
easy to browse, install, and keep track of updates on your device.
Mainly, it updates your app when necessary. (Or just have a look at its source code for inspiration on how to do it).
Yes but as far as I remember only if you had Root privileges in order to have access to the INSTALL_PACKAGES permission.
I port my android apps for making bb10 builds . Since now from bb10.2.1 update blackberry has introduced a new concept wherein apk's can be directly installed and can be installed in BB10 devices if the manage apps in settings menu of the phone is made ON. My question is that I wanna restrict my users from doing so and not installing the apk's into bb10 . And take download my app only from appworld.
Has anyone faced and has fixed this issue kindly tell me on how to solve the same.
Based on the Android behaviour, I don't think you can restrict users from doing so.
I haven't tried it on BlackBerry but from what you say, that option sounds analogue to the Unknown sources setting under Security settings on Android. If the user enables the installation of applications from unknown sources on their phone, there is now way to prevent the direct install of the apk (by adding something to your apk or any other way).
There is no way to restrict it to BlackBerry World only. If they get the APK, they can load it directly this way. There may be other ways around it though.
If, for example, your app is for sale and people are side loading a pirated copy, you could change your app to be free, and put some advanced functionality in your app behind an in-app purchase. That way they'll be forced to go through the storefront at some point to pay. This takes bigger changes to your app though, and the IAP implementation is likely different between BBW and GPlay.
You could also put in a version check: when your app launches, it checks a special file on your web server to see what the latest version of the app is. If they don't have the latest version, it doesn't let them use the app until they upgrade. This won't prevent side loading or piracy outright, but you can put out updates often enough to make side loading very annoying. When they are roadblocked and told to get the new version, you can link directly to the storefront to encourage them to get the latest version there.
Thirdly, and lastly, if you port your app to a BlackBerry 10 native, cascades, or WebWorks app, the app file is fully protected and can't be pirated or extracted from BlackBerry World (since the platform is secure). That will 100% protect you from piracy on BlackBerry 10.
I hope this helps!
I have developed android application.Current version is : android:versionCode="1" and android:versionName="2.0.3"
Sales Rep is going to use this application.
1 ) When They are in the field/working plac, if there are application upgrade available how we are going indicate to them?
2) Its a private application.They don't like to put in the android market place. So I thought we create one web application in PHP/other language & using that application user enter their credential/login to go home screen & in that place I want to take the my android application's version number. (that means need to show current version & new version). Is it possible to do this?
3) My application size is 7MB.So when they upgrade the application its overwriting previous version ? or uninstall application & install it?
4) When we do the application upgrade, apk file will download to the internal storage & upgrade it.after upgradehas been successfully the downloaded apk will remove it?
Thanks in advance...
I am expecting your suggestion.Please help me out from this issue
Distribution is easy: Just put you apk on some predefined loaction in web server (do not forget to configure proper mime type) - then field people will be able to install it by just clicking on link in their android webbrowser / email program.
To inform them about new version you can:
send email to them
deposit version number somewhere on webserver, and check it in your app. When new version is available you can prompt them for upgrade
There are several other Android Markets that are just apps you install and run.
You can configure them to point to your own repository of apps.
Then you just increase your apps versions number as normal, release a new version into your repository and the market app will alert the user.
Some of them don't provide security against someone finding your server and downloading the code directly, but at least they wont be in the Google Android Market for all to find.
http://f-droid.org/ can be configured to do this. There are others I can't remember at the moment.
I've built an Android application that will be used by the employees of my company (aka Enterprise).
I do NOT want this application to be distributed via Android Market (or any other Market unless it is my own Market).
I suppose my end users know very little about software distribution on mobile devices, about Android OS, and computers in general.
I'm interested in a single-click installation/upgrade.
I prefer that the APK file will be inaccessible/nontransferable after the installation.
What I've tried so far:
I've created an APK, put it on my own server protected by user-password, and added MIME type to be android package archive...
My users can log in to the server and download the APK file.
From now on it's a total mess (I've checked on different devices and OS versions):
1. Some devices will show the Downloads folder immediately after the installation, and some won't (in which case a newbie user gets lost immediately).
2. Some devices have different kinds of File Managers, so if you click on the downloaded APK, the behavior is different from device to device.
3. Click on the downloaded APK might have different behavior from double-click on the same APK.
4. Some devices will require uninstall before upgrade, while others won't.
5. etc...
All the above makes the installation very hard to impossible for a large number of my users.
I'm looking for a single-click installation: I send a link to a user, he clicks the link, the application is downloaded and installed (and nice to have: the (advanced) user does NOT have a way to access the APK).
I want something similar to the iPhone Enterprise Distribution (you get to company's server, click on a link, the application is being downloaded and installed).
If you've created some kind of easy installation, please share your experience.
Thank you.
You have to create a "installable" link, i.e. a link that when clicked produces a HTTP reply with Content-type header set to application/vnd.android.package-archive.
This is usually done by mapping the .apk file type to application/vnd.android.package-archive MIME type on your server. What kind of HTTP server are you using?
I have worked on a solution for this problem.. My solution is to email a download link to all devices with a link to the file. They download and start it, go to settings check "install from unknown sources", start the APK again (...), and install.
The upgrade sequence is much simpler, I have a hard link in the app that points to the latest version of the apk, the donwload starts and automatically laucnhes the install.
AS LONG as the APK is SIGNED with the same key, and the version code is updated you wont have any problem with the "uninstall issue"
If a user downloads my app (a .apk file) onto their android phone from the market place,
Where does the .apk file end up on their phone?
When they're running my application, if I detect that there is a new later version of the application available is it possible to from within the application that they're running download the latest version off an ftp link (I can programmatically do that now) and then replace the existing .apk that they're now running with the newer version. [Not sure about this one at all.]
Is the existing application all in memory when it's being run, so that when i download the new version, I can delete its apk file without it being locked up and replace it with the later build and then restart the app?
What's the best way to handle this scenario? I have an app where I want to ensure that users are on the latest version before they use it.
Apps are stored in /data/app see https://android.stackexchange.com/questions/3002/where-in-the-file-system-are-applications-installed.
IMHO, You should let the market manage updates for you, there's no need to bother doing anything by hand and as an user I would be "angry" if some app start downloading stuff on my phone without my consent, especially when abroad (some users are paying their datas).
If this user has rooted phone, you may use code provided in this answer: Android silent apk update.
If not, user has to be prompted, and you may start an activity with an intent (as usual), but also, before calling startActivity(intent), call intent.setDataAndType(Uri.fromFile(...)).