Detect Android orientation: landscape-Left v. landscape-Right
Date : March 29 2020, 07:55 AM
To fix this issue How can I detect which one of 4 sides of the phone is up. , Use an OrientationEventListener: mOrientationEventListener = new OrientationEventListener(this, SensorManager.SENSOR_DELAY_NORMAL)
{
@Override
public void onOrientationChanged(int orientation)
{
mDeviceOrientation = orientation;
}
};
if(mOrientationEventListener.canDetectOrientation())
{
mOrientationEventListener.enable();
}
// Divide by 90 into an int to round, then multiply out to one of 5 positions, either 0,90,180,270,360.
int orientation = 90*Math.round(mDeviceOrientation / 90);
// Convert 360 to 0
if(orientation == 360)
{
orientation = 0;
}
|
Landscape Orientation in android 3.1
Date : March 29 2020, 07:55 AM
|
Android Device Orientation is Landscape but Sensors Behaves Like the Orientation is Portrait
Tag : android , By : Thaweesak Suksuwan
Date : March 29 2020, 07:55 AM
wish helps you Found the solution. The problem is caused by some newer devices' default orientation is set landscape while the others' portrait. So the sensor manager behaves accordingly. In order to get sensor manager work as you expect you need to detect the defaultDisplayRotation of the device and change the remapCoordinateSystem() parameter logic. SensorManager.remapCoordinateSystem(Rmat, SensorManager.AXIS_Y, SensorManager.AXIS_MINUS_X, R2);
int rotation = ((WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation();
if(rotation == 0) // Default display rotation is portrait
SensorManager.remapCoordinateSystem(Rmat, SensorManager.AXIS_MINUS_X, SensorManager.AXIS_Y, R2);
else // Default display rotation is landscape
SensorManager.remapCoordinateSystem(Rmat, SensorManager.AXIS_Y, SensorManager.AXIS_MINUS_X, R2);
|
Android, landscape only orientation?
Date : March 29 2020, 07:55 AM
|
Detect if webapp is in landscape orientation and add padding-top
Date : March 29 2020, 07:55 AM
|