I am using Visual Studio 2019, C#, for Android.
I am trying to set the orientation and lock it. When I follow the examples, I get the error message:
The name 'setRequestedOrientation' does not exist in the current context
This is a stripped-down beginning of my MainActivity.cs file:
using Android.App; using Android.Widget; using Android.OS; using Android.Content; using System; using System.Text; using SQLite; using Android.Support.V4.Content; using Android; using Android.Support.V4.App; using Android.Content.PM; using System.IO; using Android.Bluetooth; using System.Collections; using Java.Util; using System.Collections.Generic; namespace Fubar { [Activity(Label = "Fubar", MainLauncher = true, Icon = "@drawable/icon", ScreenOrientation = Android.Content.PM.ScreenOrientation.Portrait)] public partial class MainActivity : Android.Support.V7.App.AppCompatActivity { public static Android.Support.V4.Widget.DrawerLayout drawerLayout; protected override void OnCreate(Bundle savedInstanceState) { Vars.Is_Land = false; base.OnCreate(savedInstanceState); Vars.thisApp = this; setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); // . // . // . What do I need to add to make this work? I assume that I have to add another "using" line.
This app has been around for a long time, so it currently supports Android 4.4.x (KitKat) and above. Do I need to stop supporting some of these early versions to get this working?
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);tothis.RequestedOrientation = ScreenOrientation.Landscape;.