user6199167 user6199167 - 1 year ago 101
Android Question

Android Screen rotation, ACCELEROMETER_ROTATION

am trying to make my Android application rotate as soon as it run and fix the rotation, i have tried a wide range of method like : Settings.System.ACCELEROMETER_ROTATION it doesn't make it rotate, but it just enable the rotate feature, i need your help thank you in advance (^_^). here is my code :


TableRow tableRow;
Time HourProgram;
RotateAnimation r;
int H = 12000, M = 1200;
int averageConsultationTime = 30;

protected void onCreate(Bundle savedInstanceState) {
setAutoOrientationEnabled(this, true);


public static void setAutoOrientationEnabled(Context context,
boolean enabled) {
Log.i("OK", "setAutoOrientationEnabledOK");
Settings.System.ACCELEROMETER_ROTATION, enabled ? 1 : 0);

public static boolean getRotationScreenFromSettingsIsEnabled(Context context) {

int result = 0;
try {
result = Settings.System.getInt(context.getContentResolver(),
} catch (Settings.SettingNotFoundException e) {

return result == 1;


Answer Source

You can just add this attribute to your activity in the AndroidManifest:


You can find more information about Android activities attributes here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download