Install Application programmatically on Android

Alkersan picture Alkersan · Jan 5, 2011 · Viewed 192.1k times · Source

I'm interested in knowing if it is possible to programmatically install a dynamically downloaded apk from a custom Android application.

Answer

Lie Ryan picture Lie Ryan · Jan 5, 2011

You can easily launch a market link or an install prompt:

Intent promptInstall = new Intent(Intent.ACTION_VIEW)
    .setDataAndType(Uri.parse("file:///path/to/your.apk"), 
                    "application/vnd.android.package-archive");
startActivity(promptInstall); 

source

Intent goToMarket = new Intent(Intent.ACTION_VIEW)
    .setData(Uri.parse("market://details?id=com.package.name"));
startActivity(goToMarket);

source

However, you cannot install .apks without user's explicit permission; not unless the device and your program is rooted.