We had a case in an internal app, where on Phones only the Portrait mode should be possible and on Tablets only the Landscape mode. So I googled a bit and tried out some things, and here is the solution I found for this problem.
First, in each Activiy in the AndroidManifest (or each Activity that should have this behaviour, but I prefer a consistent behaviour for the whole app), declare the following:
android:screenOrientation="nosensor"
This will prevent the Activity to switch orientations if the user rotates the device.
Then create a BaseActivity that all your Activities will be extending. In the onCreate we'll do the other part of the trick.

