Difference between SCREEN_ORIENTATION_USER and SCREEN_ORIENTATION_SENSOR

lal picture lal · Feb 27, 2016 · Viewed 11.2k times · Source

While developing an Android app, I've found two ActivityInfo attributes for setting the screen orientation.

The attributes having USER are as follows:

  1. SCREEN_ORIENTATION_USER
  2. SCREEN_ORIENTATION_USER_LANDSCAPE
  3. SCREEN_ORIENTATION_USER_PORTRAIT

The attributes having SENSOR are as follows:

  1. SCREEN_ORIENTATION_SENSOR
  2. SCREEN_ORIENTATION_SENSOR_LANDSCAPE
  3. SCREEN_ORIENTATION_SENSOR_PORTRAIT

What is the difference between the SCREEN_ORIENTATION_USER and SCREEN_ORIENTATION_SENSOR?

Answer

Pratik Tank picture Pratik Tank · Feb 27, 2016

From source

The attributes having USER are as follows.

SCREEN_ORIENTATION_USER

Use the user's current preferred orientation of the handset. Corresponds to SCREEN_ORIENTATION_USER.

SCREEN_ORIENTATION_USER_LANDSCAPE

Would like to have the screen in landscape orientation, but if the user has enabled sensor-based rotation then we can use the sensor to change which direction the screen is facing. Corresponds to SCREEN_ORIENTATION_USER_LANDSCAPE.

SCREEN_ORIENTATION_USER_PORTRAIT

Would like to have the screen in portrait orientation, but if the user has enabled sensor-based rotation then we can use the sensor to change which direction the screen is facing. Corresponds to SCREEN_ORIENTATION_USER_PORTRAIT.

The attributes having SENSOR are as follows.

SCREEN_ORIENTATION_SENSOR

Orientation is determined by a physical orientation sensor: the display will rotate based on how the user moves the device. Ignores user's setting to turn off sensor-based rotation. Corresponds to SCREEN_ORIENTATION_SENSOR.

SCREEN_ORIENTATION_SENSOR_LANDSCAPE

Would like to have the screen in landscape orientation, but can use the sensor to change which direction the screen is facing. Corresponds to SCREEN_ORIENTATION_SENSOR_LANDSCAPE.

SCREEN_ORIENTATION_SENSOR_PORTRAIT

Would like to have the screen in portrait orientation, but can use the sensor to change which direction the screen is facing. Corresponds to SCREEN_ORIENTATION_SENSOR_PORTRAIT.