OrientationListener
abstract classOrientationListener: SensorListener
| kotlin.Any | |
| ↳ | android.view.OrientationListener |
Helper class for receiving notifications from the SensorManager when the orientation of the device has changed.
Summary
| Constants | |
|---|---|
| static Int |
Returned from onOrientationChanged when the device orientation cannot be determined (typically when the device is in a close to flat position). |
| Public constructors | |
|---|---|
OrientationListener(context: Context!)Creates a new OrientationListener. |
|
OrientationListener(context: Context!, rate: Int)Creates a new OrientationListener. |
|
| Public methods | |
|---|---|
| open Unit |
disable()Disables the OrientationListener. |
| open Unit |
enable()Enables the OrientationListener so it will monitor the sensor and call |
| open Unit |
onAccuracyChanged(sensor: Int, accuracy: Int)Called when the accuracy of a sensor has changed. |
| abstract Unit |
onOrientationChanged(orientation: Int)Look at |
| open Unit |
onSensorChanged(sensor: Int, values: FloatArray!)Called when sensor values have changed. |
Constants
ORIENTATION_UNKNOWN
static valORIENTATION_UNKNOWN: Int
Deprecated: Deprecated in Java.
Returned from onOrientationChanged when the device orientation cannot be determined (typically when the device is in a close to flat position).
Value: -1See Also
Public constructors
OrientationListener
OrientationListener(context: Context!)
Creates a new OrientationListener.
| Parameters | |
|---|---|
context |
Context!: for the OrientationListener. |
OrientationListener
OrientationListener(
context: Context!,
rate: Int)
Creates a new OrientationListener.
| Parameters | |
|---|---|
context |
Context!: for the OrientationListener. |
rate |
Int: at which sensor events are processed (see also SensorManager). Use the default value of SENSOR_DELAY_NORMAL for simple screen orientation change detection. |
Public methods
disable
open fundisable(): Unit
Deprecated: Deprecated in Java.
Disables the OrientationListener.
enable
open funenable(): Unit
Deprecated: Deprecated in Java.
Enables the OrientationListener so it will monitor the sensor and call onOrientationChanged when the device orientation changes.
onAccuracyChanged
open funonAccuracyChanged(
sensor: Int,
accuracy: Int
): Unit
Deprecated: Deprecated in Java.
Called when the accuracy of a sensor has changed. See SensorManager for details.
| Parameters | |
|---|---|
sensor |
Int: The ID of the sensor being monitored |
accuracy |
Int: The new accuracy of this sensor. |
onOrientationChanged
abstract funonOrientationChanged(orientation: Int): Unit
Deprecated: Deprecated in Java.
Look at android.view.OrientationEventListener#onOrientationChanged for method description and usage
| Parameters | |
|---|---|
orientation |
Int: The new orientation of the device. |
See Also
onSensorChanged
open funonSensorChanged(
sensor: Int,
values: FloatArray!
): Unit
Deprecated: Deprecated in Java.
Called when sensor values have changed. The length and contents of the values array vary depending on which sensor is being monitored. See SensorManager for details on possible sensor types.
Definition of the coordinate system used below.
The X axis refers to the screen's horizontal axis (the small edge in portrait mode, the long edge in landscape mode) and points to the right.
The Y axis refers to the screen's vertical axis and points towards the top of the screen (the origin is in the lower-left corner).
The Z axis points toward the sky when the device is lying on its back on a table.
IMPORTANT NOTE: The axis are swapped when the device's screen orientation changes. To access the unswapped values, use indices 3, 4 and 5 in values[].
SENSOR_ORIENTATION, SENSOR_ORIENTATION_RAW:
All values are angles in degrees.
values[0]: Azimuth, rotation around the Z axis (0<=azimuth<360). 0 = North, 90 = East, 180 = South, 270 = West
values[1]: Pitch, rotation around X axis (-180<=pitch<=180), with positive values when the z-axis moves toward the y-axis.
values[2]: Roll, rotation around Y axis (-90<=roll<=90), with positive values when the z-axis moves toward the x-axis.
Note that this definition of yaw, pitch and roll is different from the traditional definition used in aviation where the X axis is along the long side of the plane (tail to nose).
All values are in SI units (m/s^2) and measure contact forces.
values[0]: force applied by the device on the x-axis
values[1]: force applied by the device on the y-axis
values[2]: force applied by the device on the z-axis
Examples:
-STANDARD_GRAVITY, which correspond to the force the device applies on the table in reaction to gravity.All values are in micro-Tesla (uT) and measure the ambient magnetic field in the X, Y and -Z axis.
Note: the magnetic field's Z axis is inverted.
| Parameters | |
|---|---|
sensor |
Int: The ID of the sensor being monitored |
values |
FloatArray!: The new values for the sensor. |