I want to prompt the user if this option is not enabled.
Here is another way to check this setting:
boolean isNonPlayAppAllowed = 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));
}
Uri settingsUri = Settings.Secure.CONTENT_URI;
String[] projection = new String[]{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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With