Question: I would like to do the following in my app:

* Portrait mode only for the phone
* Portrait mode and landscape mode for tablets.

I know i can easily change the orientation in the manifest file but that will affect the entire application. 

I have also thought of creating separate activities, to handle the different versions but i don't know how to detect the type of device using the application.

Does anyone know how to tackle this?

Answer: 
You have to identify the tablet with Android screen qualifiers: 
![Screen qualifiers](https://i.stack.imgur.com/mmoPw.png)

Then you put in the right layout folder the settings you want. For example you can add the attribute *orientation:portrait|landscape* only in the layout xml file for large screens, and *orientation:portrait* for all the others. See the folder structures here:

res/layout/my\_layout.xml // layout for normal screen size ("default")
res/layout-small/my\_layout.xml // layout for small screen size
res/layout-large/my\_layout.xml // layout for large screen size
res/layout-xlarge/my\_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my\_layout.xml // layout for extra large in landscape orientation

Take a look to the google guide: <http://developer.android.com/guide/practices/screens_support.html>
i suppose you can do small trick for it, try use `Configuration.screenLayout` :

```
  switch (this.getResources().getConfiguration().screenLayout) {
        case Configuration.SCREENLAYOUT_SIZE_SMALL:
                return "small";
            case Configuration.SCREENLAYOUT_SIZE_NORMAL:
                return "normal";
            case Configuration.SCREENLAYOUT_SIZE_LARGE:
                return "large";
            case 4: // screen xlarge 
                return "xlarge";
            default:
                return "undefined";
            }
        }

```

thanks