Share via


Activity.RequestedOrientation Property

Definition

Returns the current requested orientation of the activity, which is either the orientation requested in the app manifest or the last orientation given to #setRequestedOrientation(int). -or- Change the desired orientation of this activity.

public virtual Android.Content.PM.ScreenOrientation RequestedOrientation { [Android.Runtime.Register("getRequestedOrientation", "()I", "GetGetRequestedOrientationHandler")] get; [Android.Runtime.Register("setRequestedOrientation", "(I)V", "GetSetRequestedOrientation_IHandler")] set; }
[<get: Android.Runtime.Register("getRequestedOrientation", "()I", "GetGetRequestedOrientationHandler")>]
[<set: Android.Runtime.Register("setRequestedOrientation", "(I)V", "GetSetRequestedOrientation_IHandler")>]
member this.RequestedOrientation : Android.Content.PM.ScreenOrientation with get, set

Property Value

Returns an orientation constant as used in ActivityInfo#screenOrientation ActivityInfo.screenOrientation.

Attributes

Remarks

Property getter documentation:

Returns the current requested orientation of the activity, which is either the orientation requested in the app manifest or the last orientation given to #setRequestedOrientation(int).

"note"><b>Note:</b> <ul> <li>To improve the layout of apps on form factors with smallest width >= 600dp, the system ignores calls to this method for apps that target Android 16 (API level 36) or higher.</li> <li>Device manufacturers can configure devices to ignore calls to this method to improve the layout of orientation-restricted apps.</li> <li>On devices with Android 16 (API level 36) or higher installed, virtual device owners (select trusted and privileged apps) can optimize app layout on displays they manage by ignoring calls to this method. See also <see href="https://source.android.com/docs/core/permissions/app-streaming"> Companion app streaming</see>.</li> </ul>

See Device compatibility mode.

</aside>

Java documentation for android.app.Activity.getRequestedOrientation().

Property setter documentation:

Change the desired orientation of this activity. If the activity is currently in the foreground or otherwise impacting the screen orientation, the screen is immediately changed (possibly causing the activity to be restarted). Otherwise, the new orientation is used the next time the activity is visible.

"note"><b>Note:</b> <ul> <li>To improve the layout of apps on form factors with smallest width >= 600dp, the system ignores calls to this method for apps that target Android 16 (API level 36) or higher.</li> <li>Device manufacturers can configure devices to ignore calls to this method to improve the layout of orientation-restricted apps.</li> <li>On devices with Android 16 (API level 36) or higher installed, virtual device owners (select trusted and privileged apps) can optimize app layout on displays they manage by ignoring calls to this method. See also <see href="https://source.android.com/docs/core/permissions/app-streaming"> Companion app streaming</see>.</li> </ul>

See Device compatibility mode.

</aside>

Java documentation for android.app.Activity.setRequestedOrientation(int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to