Installing an Android apk programmatically - android

I am trying to install APKs from our file server, and it needs to be done silently without the user being able to choose whether or not it's installed or accept permission settings/changes. This is a legit business requirement as we are working with a device vendor to preload our applications into /system/app. This is a custom Android tablet device, and as such, our business unit want to ensure we can push app updates (i.e. force the latest version).
I understand the usual security restrictions, but there seems to be a mechanism to install applications silently for vendor/manufacture level apps. However the information on how to do this seems very spotty at best.
It seems the package installer must be in /system/app and the installer must have the same signing cert key as the app being installed. That's not a problem, but info on how to implement this feature using this flow is something I have yet to find.
Anyone ever done this before?

I'm fairly certain you'll need to ship them a custom Android ROM that allows you to be able to do this (which I doubt their business will enjoy).
The Amazon App Store on a normal device can't install silently in the background like Google Play can. Maybe the Kindle Fire can do this (I don't own one), but if it can, its because its running on a custom ROM built by Amazon.
The best thing you could do is launch an intent that tells brings the user to the app needs to be updated, which brings them to installer activity, which then requires user interaction.

Not exactly an answer. However, we recently faced similar requirement for an android client-server app.
Whenever the application contacts server with a request, it sends the current versionCode as well.
PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
//pInfo.versionCode;
//pInfo.versionName;
On server side we check the versionCode and if we have a new version, informs the client and client forces the user to upgrade to the new version. The client app will not work until it is upgraded to the new version. But obviously user can choose to not install etc.
Hope it helps.

Related

Remote update app across multiple devices

I am currently investigating ways of remotely updating an Android app installed on a number of devices. The app in question is to be used on phones which we will provide to a number of demonstrators as part of product presentations. For this reason we don't want to publish the app on Google Play to be available for the public at large.
I've read that you can restrict access to the device on Google Play, but only according to criteria such as location, device type, android version, etc. Another way is to set up a version for beta testing, for which you can select testers, however this is only available to those who are part of a Google group or a Google+ community (according to here).
I've come across another post which details how to install an apk programmatically, however it appears to install the apk automatically, ie it doesn't appear to check whether or not the update is actually a new version.
One idea I have in mind is to upload new version on a repository and broadcast to devices which have the app installed, of which we have stored device ids. Is this possible?
What we do is sync periodically to a remote server during data entry on the app. During this sync, we check to see whether the device has the latest version of the software. If it doesn't, the new apk is downloaded and the user is prompted to install the software.
This is accomplished using a separate installer app we created. We have a service that keeps the app alive in the background, so it looks like the user never actually leaves the app during the install.
Would be happy to post code on the installer.
You can see the self installer here: https://github.com/techartist/SelfInstall-Jelly-Bean/
You should try Beta by Crashlytics, it's email-based.
You should try beta or alfa testing in gplay.
Also you can hardcode the date of ending and not to open application after this date.

Android market application autoupdate

Some of the applications I have installed on my phone update automatically, I don't even have to click anything. This is the behavior I expect from the application I'm developing myself. Do I have to configure something or will android market take care of this?
This is not a behaviour you can set on the application itself. Each user chooses how the applications he downloads are updated. This is a market setting.
In the latest versions of the market, the default is now set to auto-update, but the user is free to untick the box and decide for manual updates, per application. If you open settings, you can also decide whether it's done on Wi-Fi only or on mobile data as well.
This will be done on all updates except the ones where a permission change occurred. For them, the market will still require a manual update.
Auto update is possible. But you should click app to start it at least.
In the start process, you can send the current version status to server through web service, server will identify the version if there is new version. if yes, a new version apk file will be downloaded, and the most important is how to install a apk file sliently.
Generally, you can run the
pm install -r xxx.apk
the apk will be automatically installed, and your app will be updated.
I'm almost positive you can't force users to update their installed apps, but I think it is the default behaviour of the Android Market.

Android application auto update

In one of our projects where we are implementing an application using Android/HTML5/JavaScript there is a requirement for having an Android Auto update kinda feature which is as described below:
Update Native version: The Native version of our application should be easy to update. New versions should be possible to “push”, or at least notify, the user of. Does this require that we publish it to the Android Market?
As of now Notification of the new version can be send to the device but we need an approach to automatically download the new version and install ie., either update the existing version or overwrite it. Hosting the new version in Android market is the last option according to the client
If someone/somebody has earlier come across or implemented such a feature, could you kindly reply back.
If you are using the Android market , the best solution is to just notify the user that an update is available. Depending on the update or Application you may decide not to allow the user the access the app if an update is available.
You will always need to push a new APK to the market , the user may setup the auto update feature but I believe there is no way for an app to force the setting.
Any method which will allow the app to auto update would either need more privileges from users or a routed device , which I guess is not a big enough percentage of users to try the feature.
The android market allow to auto-update applications. Is you want to do it without using the android market, your users will have to enable apk install from unknown sources and they will have to confirm each installation (unless their phones are rooted I think)
There is a nice service called http://push-link.com
This hosts you APK and manage updates. You can choose how the user is going to be notified and see the progress installation of all version.
Cheers...

How to install multiple apks at a time?

Am developing one Android application which is using thinkfreeoffice.apk for viewing documents in my application. My requirement is I have to download both my application and thinkfreeoffice apks at a time and also install both these apks at a time.
anybody did this one before?
You cannot literally, unless your application is signed with the system certificate or you are using the SDK/ADB install method from a connected PC, or you find and abuse some security bug. As a security measure, any installation done by a normal application on the phone will require the user to go through the confirmation dialog one app at a time.
What you can do is put check in your application for the one it depends on, and keep complaining/downloading/ACTION_VIEWing the downloaded package upon startup of your app until the user either decides they don't want to use your app or agrees with the system install dialogue for the app you depend on.
I think it's impossible to install multiple applications at the same time, as the user has to confirm installation for each apk.
You could of course make the user install your application first, then ask the user to install the office application after which you use an intent to start the installation or redirect them to the Market.
Similar implementations have been used in applications that use third party barcode scanning or speech recognition.

Is there a way to automatically update application on Android?

I'm developing an application that will most likely be preinstalled on devices. It will be also available on Google Play. Is there a way to update those instances that are not downloaded through Google Play, since Google Play won't notify users about an update.
I was thinking about, as suggested here, trying to contact my site periodically, and when update is available, download it.
Is there a way to do this update automatically, or even silently, so that user doesn't have to do anything (like running the package manually). Or, when my site shows update is available, to offer users an update through Google Play, even though it's not installed through Market (EDIT: This Google play option would be preferable, because than users wouldn't have to check "allow install of non-Market sources".)
i had the same issue, now i check at the start of my app if theres a new version in my configuration xml.
I compare the actual version with the tag "< app_version >1.1< /app_version >" of my configuration.xml
if its lower i ask with a custom AlertDialog if the user proceed with the upgrade
Intent intent = new Intent(Intent.ACTION_VIEW ,Uri.parse(myapk_link));
startActivity(intent);
after the download the user has to run the package manually.
if you choose the update from the Android market use:
Intent intent = new Intent(Intent.ACTION_VIEW ,Uri.parse("market://details?id=com.package.name"));
startActivity(intent);
com.package.name must be the "package" of your app
or
Intent intent = new Intent(Intent.ACTION_VIEW ,Uri.parse("market://search?q=" + APP_NAME));
startActivity(intent);
Just found a way that works. Fire an Intent for a Market that searches for my application.
Tested with OpenIntent Newsreader because for it was easy to find an older version .apk. Market finds an application, and when user clicks install, replaces older version with the one from the Market. I think that is much easier solution for a user than downloading manually .apk and running it.
Intent intent = new Intent(Intent.ACTION_VIEW ,Uri.parse("market://search?q=" + APPLICATION_NAME));
startActivity(intent);
Is there a way to update those instances that are not downloaded through Google Play, since Google Play won't notify users about an update.
Old question, new answer:
After digging on exact the same question (pre-installed app on device, how can I provide a update through Google-Play) I found this information on support.google.com*:
Google Play can manage updates to preloaded applications, provided the following conditions are met:
The preloaded app needs to be in the system partition
The preloaded app needs to be free
The preloaded app needs to be signed with the same signature as the app published in Google Play
The Package Name of the preloaded and updated app needs to be the same
The Version Code of the updated app needs to be greater than that of the preloaded app
* as of 2015-04-13
I'm developing an application that
will most likely be preinstalled on
devices.
Then you need to be talking to the device manufacturers and asking them your questions. Nobody else will be able to tell you what is and is not possible, given their device and the carrier(s) that will distribute it. The answers will depend heavily on how they create their firmware, whether your application will be part of the firmware or "installed" as a normal app, what their arrangement with the carrier is vis a vis firmware updates, etc. You may not even get a vote in the matter.
Here is the option for latest version update
https://developer.android.com/guide/app-bundle/in-app-updates#update_readiness
try this google library to update from the application
dependencies {
implementation 'com.google.android.play:core:1.5.0'
...}
I hope this will help anyone
If whoever bundled the app on the device does a proper job of it, then the app will still have a market link (even as a system app) and Market will prompt the user to upgrade it if a new version is available. After all, that's exactly what happens with an app like GMail that's pre-installed on phones.
You cannot install or upgrade a package automatically. Only the Android Market is capable of doing this (i.e. it silently updates itself).
You can certainly download a package and fire the Intent to install it, but the user will have to have the "Allow non-Market apps" options enabled, and they'll still have to manually approve the install/upgrade.
One place to possibly investigate is how Google Maps does it. This is generally pre-installed, but always appears to be shown as an update in the Android Market app, I believe. Whether there's a special flag in the packages.xml or manifest, I don't know.
There is a nice service that helps your app keep itself updated. Take a look at https://www.pushlink.com
In this product there is a NINJA mode that allows to perform updates without user interaction.
For other "modes", enabling "Install non-market app" is still needed. If it not enabled, the installation process is going to ask for it and redirect the user to the Application Settings, and after that, the user can install the app.
It's possible to fully automatically update an app, if you can sign an app as a system app. We wrote an app for specific hardware, we created an update app that the manufacturer signed for us. The update app runs on device startup, checks current version of the app and the new version, and installs the new version if necessary.
The use case would be a kiosk app, on tablets of one make and model, that don't have Google Play.
Google in 2018 Android dev summit announced android in-app update api's for developers so you can read whole story out here and get updated on this question.Android in-app update api details
https://developer.android.com/guide/app-bundle/in-app-updates

Categories

Resources