Here is a preview for the same: Steps for Locking Screen Orientation. In this tutorial we are changing the current screen orientation mode on button clicks using setRequestedOrientation method. So here is the complete step by step tutorial for Change screen orientation in android programmatically. We will go into details with the two processes. I use the following environment and tools in this tutorial but you are free to use whatever tools you are familiar with. Another way is to set the orientation programmatically: Just call this.RequestedOrientation = ScreenOrientation.Portrait; in OnResume() to set it to portrait for example.. It is very common that during development, one may find very useful to lock/unlock the device screen during specific parts of the code.. For instance, while showing a Dialog with information, the developer might want to lock the screen's rotation to prevent the dialog from being dismissed and the current activity from being rebuilt to unlock it again when the dialog is dismissed. Android supports two orientations as portrait and landscape. Example. Android 7.0 adds support for displaying more than one app at the same time. Android screen orientation can be accomplish from android configuration file or programmatically. But sometimes some of application dose not required changing screen orientation so android app developer can stop android app layout orientation moving using single function. This method will help us to change the screen orientation after start activity using MainActivity.java file. To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. I am testing my experimental launcher app, and using a customer button, I am trying to lock the orientation of the device by calling the following code: mainActivity.RequestedOrientation = ScreenOrientation.Locked; but it only works just for the launcher app. Default value is taken from the 'Default Orientation' in Player Settings. . How to lock screen orientation on all android devices programmatically? Windows 7 Android Studio Samsung Galaxy Fame Lite Min SDK 8 Target SDK 19 we can disable orientation in android application. android documentation: Lock Screen's rotation programmatically. As an example, if we take 480x320 resolution on iPhone, horizontal orientation is treated as 480x320 resolution and vertical orientation as 320x480. This example demonstrate about how to disable landscape mode in Android. Portrait – forces the application orientation to be portrait, regardless of sensor data. Please Note! And how to make one of the Activity should be in portrait mode and all the other activities should be set at auto screen orientation? If you have a BaseActivity that all your other Activities are extending, you will just have to do it once.. On handheld devices, two apps can run side-by-side or one-above-the-other in split-screen mode. Xamarin.Android supports several options for specifying orientation: Landscape – forces the application orientation to be landscape, regardless of sensor data. Step 1: Create a New Project. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. On TV devices, apps can use picture-in-picture mode to continue video playback while users are interacting with another app. It does not change the lock on the orientation of the device as a whole. Note: logical orientation affects not only screen orientation, but also touch coordinates. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and … User – causes the application to be presented using the user's preferred orientation. Hi together! This example demonstrate about How to lock the Android device programmatically.