Akh
Akh

Reputation: 6043

How to use default Package Installer (Android) when trying to install an APK from another app?

I have been trying to install other apps from my app. I have downloaded the .apk from the server and I am firing an intent with the following content

Intent installIntent = new Intent(Intent.ACTION_INSTALL_PACKAGE);

installIntent.setData(Uri.parse("file:<apk file location>"));
installIntent.putExtra(Intent.EXTRA_INSTALLER_PACKAGE_NAME, DOWNLOADED_PACKAGE_NAME);
installIntent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
installIntent.putExtra(Intent.EXTRA_RETURN_RESULT, true);

startActivityForResult(installIntent, REQUEST_INSTALL); 

How to avoid this prompt?

This feature has been added since 4.2 ONLY.

enter image description here

Upvotes: 4

Views: 20250

Answers (1)

Ricky
Ricky

Reputation: 41

Problem Solved.

    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setClassName("com.android.packageinstaller", "com.android.packageinstaller.PackageInstallerActivity");

Upvotes: 4

Related Questions