1

I'm developing an app targeting android 4+, that behaves differently depending on screen size. More in detail:

  • On small/medium screens, orientation is forced on portrait, and app runs by switching activities.
  • On large/x-large screens, orientation is forced on landscpe, screen is split into two, with the menu fragment on the left, and other fragments on the right.

Problem is, I can't create an AVD that gets detected as a large screen.

Just tested on an AVD with 640x1024 resolution, 240 density, this code never goes into the first IF.

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    // forcing layout to landscape if display is LARGE or more
    if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE ||
            (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        dualPane = true;
    }
    else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        dualPane = false;
    }
}

Any help?

Pimentoso
  • 673
  • 8
  • 14

1 Answers1

0

Assuming you have the Android SDK plugins for Eclipse installed, you can create an emulator that uses only LARGE layouts:

  1. In Eclipse, click on the little green Android button (to "Open the Android Virtual Device Monitor").
  2. New...
  3. Name = [Whatever]
  4. Target = Android 4.x
  5. CPU/ABI = [Whatever] but the Intel emulators are often better/faster.
  6. Resolution = 1024 x 600. This is the important part. Don't use 600 x 1024. It must be a landscape device (like a 'Mini Tablet')
  7. Also important: Set the density manually to MDPI: Click on "Abstracted LCD density" -> Change the number to 160 for MDPI.
  8. Create AVD

Now start the device. It will only use LARGE layouts (Configuration.SCREENLAYOUT_SIZE_LARGE). Rotate to portrait using Ctrl+F11. Portrait mode will also use LARGE layouts.

user2129417
  • 125
  • 1
  • 3
Mr-IDE
  • 7,051
  • 1
  • 53
  • 59