Skip to content

Most visited

Recently visited

navigation

Unknown App Install Permissions

Android O uses a new system for unknown apps, allowing users to choose which apps can install unknown apps onto their devices.

Sometimes, users install apps using a source or unknown source, an app other than a first-party app store that can install other apps. The apps installed using these unknown sources are called unknown apps.

Prior to Android O, users who wished to install unknown apps using a particular unknown source needed to enable the Allow unknown sources system setting. When enabled, however, this setting allowed the device to install unknown apps from any unknown source.

To give users more flexibility and control with using unknown sources, Android O has removed the Allow unknown sources system setting, replacing it with a new runtime permission called Install unknown apps. Before a source attempts to install an unknown app, the user must first explicitly grant the source permission to install unknown apps. Users can grant or revoke this permission for a particular source at any time.

Updating your app's manifest

If your app targets Android O (API level 26) or higher, you need to indicate in your app's manifest file that your app uses the new Install unknown apps permission. To do so, add the REQUEST_INSTALL_PACKAGES permission, as shown in the following code snippet:

<manifest>
    <uses-permission
        android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
    <application>
      ...
    </application>
</manifest>

After completing this step, your app can continue to trigger APK installs using the package installer APIs.

You should also know how users can change the Install unknown apps permission to allow your app to install unknown apps or prevent your app from doing so. The following section explains how this process works.

Checking your app's permission status

If your app targets Android O (API level 26) or higher, it can check whether the user has granted your app permission to install unknown apps by calling canRequestPackageInstalls(). If this method returns false, the user hasn't yet granted your app permission to install unknown apps.

In most cases, you can rely on the package installer app to guide the user to the Install unknown apps settings screen, where they can grant your app permission to install unknown apps. Figure 1 shows how this workflow appears on the user's device:

Typical unknown app install workflow in Android O.
Figure 1. The system dialog directing users to a settings screen, and the settings screen where users grant permission for a source to install unknown apps

If desired, however, you can simplify this experience using the ACTION_MANAGE_UNKNOWN_APP_SOURCES intent action, which sends users directly to the Install unknown apps settings screen. The following code snippet demonstrates how to identify whether your app can install unknown apps, as well as how to direct users to the settings screen where they grant the necessary permission:

public static final Uri PACKAGE_URI =
        Uri.parse("package:com.example.myunknownappinstaller");
public static final int UNKNOWN_APP_REQUEST_CODE = 1;

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (getPackageManager().canRequestPackageInstalls()) {
        // The user has already granted your app permission to install
        // unknown apps. You can now request an unknown app install.
    } else {
        // The user hasn't yet granted your app permission to
        // install unknown apps.
        Log.d(MY_APP_TAG, "Not allowed to install unknown apps yet!");

        // Directs the user to their device's settings screen, where they can
        // grant permission for your app to install unknown apps.
        Intent settingsIntent = new Intent()
                .setAction(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES)
                .setData(PACKAGE_URI);
        startActivityForResult(settingsIntent, UNKNOWN_APP_REQUEST_CODE);
    }
    // ...
}
This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.