Search code examples
androidandroid-layoutscreen-orientation

Orientation Locking to landscape not working on emulator but on device


I have used following code in activity onCreate() to lock view only to landscape mode, it is perfectly working on device but not working on emulator, Since i dont have a device now it's hard to develop

code :

  setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
  setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);

Please help


Solution

  • Try this:

    android:screenOrientation="sensorLandscape"

    Put this Code[Attribute] in Activity tag of AndroidManifest.xml file it should work.