androidapk

Install Application programmatically on Android


Is possible to programmatically install a dynamically downloaded apk from a custom Android application.


Solution

  • 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.