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.
Related
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.
My application suite is composed of multiple APKs corresponding to different applications. Installation of the different APKs should done in parallel so that to avoid user having older version for some app and newer version for other apps.
In the current approach, the user has to install each of the APK explicitly. If one of the APP is not updated with newer version, then it becomes an issue.
Is there a way to install multiple APKs corresponding to different App in one go ?
I guess the answer depends on what you want to achieve here.
If you want a single app to be able to install other apps without asking the user for his opinion, the answer clearly is no, and for good reasons:
The apps automatically installed would not be able to display their required permissions, which is a rule from Google Play in principle.
This behavior could be dangerous as it would then be easy for someone to produce for instance a game app and add a malware to it that would automatically install as well and sneak into the devices of whoever would use the app.
But there is an alternative to it, requiring the intermediate of a computer.
The project Mass APK Installer Tool was designed for exactly this purpose.
Check this article about Mass APK Installer Tool. The link to the code is broken as it has moved to its new location, here.
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!
For instance, Hangout allows you (on an old phone) to uninstall the updates to downgrade it to GTalk.
Can I allow the user to do so with my app?
I mean, I will push an update on the store, will we be able to uninstall this update and restore to the previous version?
No, you cannot. What you're describing only works in situations where the downgrade is resident in the device's /system partition (meaning it was pre-installed when the device firmware was built). Unless you're building your own ROM with the application resident, the old version won't be there to downgrade to.
Note that when building ROMs there are two ways to provide applications -- one by simply placing the APK into the right directory in /system, and the other by placing it somewhere that some other code locates and performs a pm install on. The downgrade feature is only possible when the APK has simply been placed where it needs to be with no pm install required.
As far as my understanding goes in the case of Hangouts/GTalk: GTalk is most likely installed as a system app, Hangouts is an update to GTalk which also renames the application. As with every application installed as a system app and updated via Google Play, the user may decide to remove the update (same as uninstalling any non-system app), thus restoring the factory-version of that app.
When updating an application which was previously installed via Google Play, the old version does not remain in the system. Therefore, I doubt that restoring an old version is possible when using Google Play to distribute your app.
If you really want your users to be able to go back to previous version, you should consider hosting older versions of your app on some sort of web server / dropbox / ftp / etc. Users may then grab those files and do a manual downgrade.
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(...)).