¿Hay alguna manera de comprobar si "Instalar desde fuente desconocida" está habilitado en Android?
Quiero pedir al usuario si esta opción no está habilitada.
Aquí hay otra manera de comprobar esta configuración:
boolean isNonPlayAppAllowed = Settings.Secure.getInt(getContentResolver(), Settings.Secure.INSTALL_NON_MARKET_APPS) == 1;
También este código para mostrar la configuración de usuario me podría ser útil:
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 }