1

I am converting and android handset application to tablet (1024*600 and 1280*720). I have given the support for different screen- size, but stuck in orientation part. I want some pages to be visible as landscape. For example after logged in by user the next intent should be in landscape form. After searching I found clue but not very understandable answer such as

  1. By adding activity in manifest.xml file

  2. At runtime by using getOrientation().

Thanks

JNI_OnLoad
  • 5,472
  • 4
  • 35
  • 60
  • try to set like setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); on the activity where ever you need landscape. – Raj Jan 08 '13 at 10:38
  • "I want some pages to be visible as landscape". What if the screen is in portrait mode? – Zyoo Jan 08 '13 at 10:42
  • I did this by adding activity in manifest.xml file. But I am wondering if it will work when auto-rotation mode is enable. I think it will work but will look bad. Could you make me clear. – JNI_OnLoad Jan 08 '13 at 10:55
  • Have you set in your layout for example `layout-sw600dp-land` or `layout-large-land`? If screenOrientation is `"unspecified"` that means the orientation can change automatic from the system. – Zyoo Jan 08 '13 at 11:04

1 Answers1

0

The question is not clear, if you're forcing screen orientation by size (e.g. on tablet device there's only landscape orientation), i think you should get the screen width and height first then evaluate it. If the screen width and height are 1024*600 or 1280*720, you change the orientation with setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

To get the width and height, do this in your activity:

Display display = getWindowManager().getDefaultDisplay();
int width, height;
try {
    Point size = new Point();
    display.getSize(size);
    width = size.x;
    height = size.y;
}
catch (NoSuchMethodError e) {
    width = display.getWidth();
    height = display.getHeight();
}

See this

Community
  • 1
  • 1
Zyoo
  • 773
  • 10
  • 30
  • I think checking width and height is not needed, setting layout-sw600dp-land or layout-large-land is enough as android automatically sense it and display the respective data accordingly.BTW thanks for help. – JNI_OnLoad Jan 08 '13 at 13:09