Is there anyway to find out if a device is portrait or landscape by default? In that I mean how you normally use the device.
Most phones have a portrait screen for
I had a similar issue. Solved it by comparing values of rotation and orientation. There is no need to use sensors or any listeners, just call isDefaultLandscape
method whenever you wish.
private boolean isDefaultLandscape(final Context context)
{
Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
int rotation = display.getRotation();
int orientation = context.getResources().getConfiguration().orientation;
switch (rotation)
{
case Surface.ROTATION_180:
case Surface.ROTATION_0:
{
return orientation == Configuration.ORIENTATION_LANDSCAPE;
}
default:
{
return orientation == Configuration.ORIENTATION_PORTRAIT;
}
}
}