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?

Bondolin
  • 2,793
  • 7
  • 34
  • 62
Tal Kanel
  • 10,475
  • 10
  • 60
  • 98

2 Answers2

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.

Bondolin
  • 2,793
  • 7
  • 34
  • 62
Guillaume
  • 22,694
  • 14
  • 56
  • 70
  • 1
    actually I need it because I'm developing an application that needs to update itself automatically without user interaction. – Tal Kanel Nov 10 '11 at 10:13
  • Ah, so that might be possible, if it's the same application... I'll do more research on this, I'm interested... – Guillaume Nov 10 '11 at 10:19
  • 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 . – moujib Nov 10 '11 at 10:25
  • @moujib: agreed, that would be the preferred, documented, secured way, and consistent with the android ecosystem. Still, it's an interesting theoretical question. – Guillaume Nov 10 '11 at 10:27
  • @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 for – Tal Kanel Nov 10 '11 at 11:03
  • 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. – Guillaume Nov 10 '11 at 11:04
  • 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) – Tal Kanel Nov 10 '11 at 11:29
  • "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) – Guillaume Nov 10 '11 at 11:33
  • See section : Publishing Updates on Android Market here : http://developer.android.com/guide/publishing/publishing.html#market and section : Linking to Your Apps on Android Market – moujib Nov 10 '11 at 15:53
  • @moujib 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 device – TimothyP Jun 16 '14 at 07:43
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.

Bondolin
  • 2,793
  • 7
  • 34
  • 62
tanmeet
  • 220
  • 2
  • 11