Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between SCREEN_ORIENTATION_USER and SCREEN_ORIENTATION_SENSOR

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?

like image 940
lal Avatar asked Feb 27 '16 10:02

lal


People also ask

What is the meaning of screen orientation?

Screen Orientation, also known as screen rotation, is the attribute of activity element in android. When screen orientation change from one state to other, it is also known as configuration change.

How do I manage different orientations in Android?

If you want to manually handle orientation changes in your app you must declare the "orientation" , "screenSize" , and "screenLayout" values in the android:configChanges attributes. You can declare multiple configuration values in the attribute by separating them with a pipe | character.

What happens when screen orientation changes in Android?

When you rotate your device and the screen changes orientation, Android usually destroys your application's existing Activities and Fragments and recreates them. Android does this so that your application can reload resources based on the new configuration.

How many types of orientation is used with Android screen explain with code?

As with almost all smartphones, Android supports two screen orientations: portrait and landscape. When the screen orientation of an Android device is changed, the current activity being displayed is destroyed and re-created automatically to redraw its content in the new orientation.


1 Answers

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.

like image 136
Pratik Tank Avatar answered Sep 18 '22 19:09

Pratik Tank