public abstract class OrientationEventListener extends Object
Modifier and Type | Field and Description |
---|---|
static int |
ORIENTATION_UNKNOWN
Returned from onOrientationChanged when the device orientation cannot be determined
(typically when the device is in a close to flat position).
|
Constructor and Description |
---|
OrientationEventListener(Context context)
Creates a new OrientationEventListener.
|
OrientationEventListener(Context context,
int rate)
Creates a new OrientationEventListener.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canDetectOrientation() |
void |
disable()
Disables the OrientationEventListener.
|
void |
enable()
Enables the OrientationEventListener so it will monitor the sensor and call
onOrientationChanged(int) when the device orientation changes. |
abstract void |
onOrientationChanged(int orientation)
Called when the orientation of the device has changed.
|
public static final int ORIENTATION_UNKNOWN
onOrientationChanged(int)
,
Constant Field Valuespublic OrientationEventListener(Context context)
context
- for the OrientationEventListener.public OrientationEventListener(Context context, int rate)
context
- for the OrientationEventListener.rate
- at which sensor events are processed (see also
SensorManager
). Use the default
value of SENSOR_DELAY_NORMAL
for simple screen orientation change detection.public void enable()
onOrientationChanged(int)
when the device orientation changes.public void disable()
public boolean canDetectOrientation()
public abstract void onOrientationChanged(int orientation)
ORIENTATION_UNKNOWN
is returned when the device is close to flat
and the orientation cannot be determined.orientation
- The new orientation of the device.ORIENTATION_UNKNOWN