2011-07-12 7 views

Respuesta

4
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 
} 
11

Aquí es otra manera de comprobar este ajuste:

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 podría yo útil:

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

tuve que usar android.provider. Settings.Secure ... –

Cuestiones relacionadas