Skip to content Skip to sidebar Skip to footer

Is There A Way To Check If "install From Unknown Source" Is Enabled On Android?

I want to prompt the user if this option is not enabled.

Solution 1:

Here is another way to check this setting:

booleanisNonPlayAppAllowed= Settings.Secure.getInt(getContentResolver(), Settings.Secure.INSTALL_NON_MARKET_APPS) == 1;

Also this code to show the setting to user might me useful:

if (!isNonPlayAppAllowed) {
    startActivity(new Intent(android.provider.Settings.ACTION_SECURITY_SETTINGS));
}

Solution 2:

Uri settingsUri = Settings.Secure.CONTENT_URI;
String[] projection = newString[]{Settings.System.VALUE};
String selection = Settings.Secure.NAME + " = ? AND " +
        Settings.Secure.VALUE + " = ?";
String[] selectionArgs = {Settings.Secure.INSTALL_NON_MARKET_APPS,
    String.valueOf(1)};
Cursor query = getContentResolver().query(settingsUri, projection,
    selection, selectionArgs, null);
if (query.getCount() == 1) {
    // it's enabled
} else {
    // it's not
}

Post a Comment for "Is There A Way To Check If "install From Unknown Source" Is Enabled On Android?"