Can an Android app install another android app?
Asked Answered
E

5

18

I was wondering if it was possible to have an android app which is already installed go and download another app and install it? I figure there could be security problems with this, but is it possible for the Android OS to do this?

Exhale answered 22/6, 2010 at 17:56 Comment(1)
I think one thing many of these answers failed to mention is system apps and their special ability to have the INSTALL_PACKAGES permission. If you need examples of such system apps, the fdroid privileged extension app is a good example, or AuroraServices(a fork of the fdroid privileged extension app). These work in the background to invoke the system installer without alerting the userMuscarine
P
24

Strictly speaking no, it is not possible: each Android package (.apk) file installed on the device is given its own unique Linux user ID, creating a sandbox for it and preventing it from touching other applications.
If an application would "install" another one, it couldn't give to the target a new user ID. Only the system applet, running at root level, can do that.

What the application can do is to indirectly invoke the package installer with the ACTION_VIEW intent and the application/vnd.android.package-archive MIME type: the system will launch the appropriate "viewer", which of course is the package installer.

Nice link about that topic: http://android.amberfog.com/?p=98

Pelvis answered 22/6, 2010 at 18:0 Comment(6)
Just for completeness, I want to point out that your answer precludes a rooted device.Sorensen
Is there no way to get the system to ask the user for permission like Rpond suggested?Exhale
@Chapso: of course, on rooted devices you can do whatever you want, but in this case why asking if there is a "legitimate" way?Pelvis
@Anton: sure, you have just to view the file, the system will detect the file type and launch the appropriate viewer, the installer in our case!Pelvis
By the way... this is how to invoke the viewer: https://mcmap.net/q/669162/-automatic-install-of-apkPelvis
The link in the answer helped a lot.Exhale
P
11

Yes. This is how the Swype beta works. What you basically do is download the new apk, and use some Intent (not sure which) to launch the Package Installer (and at this point it is a new activity and the user has to agree to install just like downloading from the Market).

Pristine answered 22/6, 2010 at 18:4 Comment(2)
This is correct. You just need to launch a View intent on the apk.Saviour
This is not installing an app.... this is calling the system installer... that's a huge difference...Pelvis
H
10

Try this:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(path+"/yourapp.apk")), application/vnd.android.package-archive");
startActivity(intent);
Horologium answered 17/1, 2012 at 5:15 Comment(1)
your forgot a Apostroph in: "application/vnd.android.package-archive"Halvorson
L
5


If the answer is NO. Then i wonder how facebook installs "Messenger" Application along with the "Facebook for Android" application?

If i'm not wrong, "Messenger" is also a different application from Main Facebook app.

Facebook For Android App will not ask to install Messenger App when we want to chat thru facebook app. It is already installed with facebook.

You can also install/uninstall Messenger application separately.

I may be wrong. I dont have complete information, but looking at the process and on applying little bit of logic i think we can install android application from another application. But how i'm too learning and looking for it .


So how must they have done it? Please correct me if i'm wrong.

Lauricelaurie answered 12/6, 2012 at 7:46 Comment(4)
I'm not sure. I can't test it out myself because my non-rooted android phone does not allow me to uninstall the Facebook app and reinstall it. I would guess that the Facebook app is allowed special privileges that normal apps do not have. Similar to how I am unable to uninstall the Facebook app from my phone without rooting my phone. I don't think Google would allow normal android applications to install other applications without the user's consent. Even application who are given Device Administration do not have the ability to install other apps.Exhale
That is done using multiple Launcher/Main activities in the Android Manifest xml. If you define two there, you see two shortcuts as launchers.Qualification
Facebook was also disabled from the Play Store at one point due to it "Breaking terms of service" by programatically modifying itself and it's other "apps" without going through the app store. Worth mentioning.Lysol
@RavindranathAkila you are right. I too have figured it out. We can add launchers to the any activity and that will be shown in the apps menu list.Lauricelaurie
S
0

If your app is root privlaged you can move the apk you want to install into /data/app and it will install when the device reboots

Spanker answered 12/1, 2015 at 11:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.