2012-10-12 9 views
6

Sto lavorando a un'app per Android, per la quale mi piacerebbe sapere se la rotazione automatica è abilitata. Qualcuno sa come posso ottenere questo? Quindi, solo per chiarezza: ho solo bisogno di sapere se un utente ha o meno la rotazione automatica abilitata nelle impostazioni o meno.Ottieni informazioni di rotazione automatica su Android

risposta

14

È possibile ottenere Ruota automaticamente informazioni On/Off Utilizzando Settings.System.ACCELEROMETER_ROTATION come:

if (android.provider.Settings.System.getInt(getContentResolver(),Settings.System.ACCELEROMETER_ROTATION, 0) == 1){ 
Toast.makeText(Rotation.this, "Rotation ON", Toast.LENGTH_SHORT).show(); 

} 
else{ 
Toast.makeText(Rotation.this, "Rotation OFF", Toast.LENGTH_SHORT).show(); 
} 
+0

Works! Grazie mille! – Zero

+0

@Legion: firend molto gradito !!!! :) –