Android APK's Silent Installation
Asked Answered
G

2

10

I'm searching for a way to program my application to install silently an APK file. I'm aware about the possibility to launch with code that looks something like this:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");
startActivity(intent);   

But before the installation starts, this code raises a dialog with the APK's required permissions, and needs user authorization to start the installation.

Is there any way to skip this dialog?

Is there any other way to install an application during runtime from my code, that doesn't require user interaction?

Gamma answered 10/11, 2011 at 10:4 Comment(1)
I want to know more about silent uninstall also.Latanya
F
10

No. And that's a good thing - this would be an (other) open door to malware and unwanted installs. Why do you want to do that, if you mind me asking? What's wrong with letting users know that you want to install something on their device?

Also, some details here: Silent installation on Android devices

And finally, this might be possible for rooted devices: if you write your own installer, you can bypass completely the built-in installer, and with root privilege, you can basically do what you want. But I still think that would be a serious breach of security.

Fuzee answered 10/11, 2011 at 10:7 Comment(10)
actually I need it because I'm developing an application that needs to update itself automatically without user interaction.Gamma
Ah, so that might be possible, if it's the same application... I'll do more research on this, I'm interested...Fuzee
Push the update through the Market ! And when an update is available implement some logic to tell the user to open the Market and update your app .Dowery
@moujib: agreed, that would be the preferred, documented, secured way, and consistent with the android ecosystem. Still, it's an interesting theoretical question.Fuzee
@moujib: thank's, I'll be glad if you can be more specific about how can I "listen" from my application to updates, and if you have any idea what kind of logic will do the silent installation process I'm looking forGamma
The market doesn't work this way: your application doesn't listen to it, it's done natively by the android market app: if the user checks auto-updates, then it does it, else he needs to visit the market to get the update.Fuzee
ok, but maybe at least there's a way to declare somehow in the code something that will make the "allow automatic updates" CheckBox on market availble/visible ? (I noticed some application have this feature visible in the market, and some of them don't)Gamma
"allow automatic updates" is not great at the moment though, because it updates even when on mobile data and potentially kills your bandwidth and your allowance... Most people leave it off until it's fixed and you have an option to select WiFi only (which I heard will happen soon)Fuzee
See section : Publishing Updates on Android Market here : developer.android.com/guide/publishing/publishing.html#market and section : Linking to Your Apps on Android MarketDowery
@Dowery that is assuming the application is intended for the Market or even for a mobile device. Android is more than an OS for mobile devices, sometimes people want to build an entire solution on top of it to run on an embedded deviceOsmometer
S
0

Yes you can, but you need root access or your app must be a system signed app.

You can install apps silently by using shell commmand pm install "apk path".

This will definitely work - I have already created a sample app that does this.

Shewmaker answered 11/7, 2016 at 6:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.