madeeha ameer
madeeha ameer

Reputation: 499

How can i install multiple APKs from my application's single APK?

I am making an application in which i want to call some other apks (which are not pre-installed) and they are present in the sd card of my phone and I want them to install when the main app gets installed. Is this possible? And how?

Upvotes: 2

Views: 711

Answers (1)

Raghav Sood
Raghav Sood

Reputation: 82563

You can use the following Intent to request Android to install your APK:

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

Keep in mind that the user can cancel this install process. Also, if the APKs are on the external storage you will need permission to read from external storage. Additionally, the device must be enabled to allow sideloading.

You cannot install APKs silently as Google Play does on an unrooted device for security reasons.

Even though you say your APKs are located on the SD Card, it's worth mentioning for future readers over here than installation of APKs from the /assets directory isn't supported. Instead, you must copy the APK to either the internal or external storage, and then use the Intent with the required path.

Upvotes: 3

Related Questions