How to use the default package installer (Android) when trying to install the APK from another application?

I am trying to install other applications from my application. I downloaded .apk from the server and I fire the 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); 
  • But I am trying to install the default installer while trying to install the package.
  • The following prompt appears after I started the installation intent, ask the user to select the default application to handle the intent, which is undesirable.
  • This prompt should not be displayed to the user.
  • The desired behavior is to start installing the package after the download is completed, for example, on Google Play.
  • Click "Install" → Download → Set permission → Install.

How to avoid this invitation?

This feature is added with 4.2 ONLY.

enter image description here

+4
source share
1 answer

The problem is resolved.

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

Source: https://habr.com/ru/post/1498289/


All Articles