public class OrientationSensor extends AndroidNonvisibleComponent implements android.hardware.SensorEventListener, Deleteable, OnPauseListener, OnResumeListener
form
ACCELEROMETER_SENSITIVITY_MODERATE, ACCELEROMETER_SENSITIVITY_STRONG, ACCELEROMETER_SENSITIVITY_WEAK, ALIGNMENT_CENTER, ALIGNMENT_NORMAL, ALIGNMENT_OPPOSITE, ASSET_DIRECTORY, BUTTON_SHAPE_DEFAULT, BUTTON_SHAPE_OVAL, BUTTON_SHAPE_RECT, BUTTON_SHAPE_ROUNDED, COLOR_BLACK, COLOR_BLUE, COLOR_CYAN, COLOR_DEFAULT, COLOR_DKGRAY, COLOR_GRAY, COLOR_GREEN, COLOR_LTGRAY, COLOR_MAGENTA, COLOR_NONE, COLOR_ORANGE, COLOR_PINK, COLOR_RED, COLOR_WHITE, COLOR_YELLOW, DEFAULT_VALUE_COLOR_BLACK, DEFAULT_VALUE_COLOR_BLUE, DEFAULT_VALUE_COLOR_CYAN, DEFAULT_VALUE_COLOR_DEFAULT, DEFAULT_VALUE_COLOR_DKGRAY, DEFAULT_VALUE_COLOR_GRAY, DEFAULT_VALUE_COLOR_GREEN, DEFAULT_VALUE_COLOR_LTGRAY, DEFAULT_VALUE_COLOR_MAGENTA, DEFAULT_VALUE_COLOR_NONE, DEFAULT_VALUE_COLOR_ORANGE, DEFAULT_VALUE_COLOR_PINK, DEFAULT_VALUE_COLOR_RED, DEFAULT_VALUE_COLOR_WHITE, DEFAULT_VALUE_COLOR_YELLOW, DIRECTION_EAST, DIRECTION_MAX, DIRECTION_MIN, DIRECTION_NONE, DIRECTION_NORTH, DIRECTION_NORTHEAST, DIRECTION_NORTHWEST, DIRECTION_SOUTH, DIRECTION_SOUTHEAST, DIRECTION_SOUTHWEST, DIRECTION_WEST, FONT_DEFAULT_SIZE, LAYOUT_ORIENTATION_HORIZONTAL, LAYOUT_ORIENTATION_VERTICAL, LENGTH_FILL_PARENT, LENGTH_PREFERRED, LENGTH_UNKNOWN, SLIDER_MAX_VALUE, SLIDER_MIN_VALUE, SLIDER_THUMB_VALUE, TOAST_LENGTH_LONG, TOAST_LENGTH_SHORT, TYPEFACE_DEFAULT, TYPEFACE_MONOSPACE, TYPEFACE_SANSSERIF, TYPEFACE_SERIF
Constructor and Description |
---|
OrientationSensor(ComponentContainer container)
Creates a new OrientationSensor component.
|
Modifier and Type | Method and Description |
---|---|
float |
Angle()
Angle property getter method (read-only property).
|
boolean |
Available()
Available property getter method (read-only property).
|
float |
Azimuth()
Azimuth property getter method (read-only property).
|
boolean |
Enabled()
Enabled property getter method.
|
void |
Enabled(boolean enabled)
Enabled property setter method.
|
float |
Magnitude()
Magnitude property getter method (read-only property).
|
void |
onAccuracyChanged(android.hardware.Sensor sensor,
int accuracy) |
void |
onDelete() |
void |
onPause() |
void |
onResume() |
void |
onSensorChanged(android.hardware.SensorEvent sensorEvent)
Responds to changes in the accelerometer or magnetic field sensors to
recompute orientation.
|
void |
OrientationChanged(float azimuth,
float pitch,
float roll)
Default OrientationChanged event handler.
|
float |
Pitch()
Pitch property getter method (read-only property).
|
float |
Roll()
Roll property getter method (read-only property).
|
getDispatchDelegate
public OrientationSensor(ComponentContainer container)
container
- ignored (because this is a non-visible component)public void OrientationChanged(float azimuth, float pitch, float roll)
This event is signalled when the device's orientation has changed. It reports the new values of azimuth, pich, and roll, and it also sets the Azimuth, Pitch, and roll properties.
Azimuth is the compass heading in degrees, pitch indicates how the device is tilted from top to bottom, and roll indicates how much the device is tilted from side to side.
public boolean Available()
true
indicates that an orientation sensor is available,
false
that it isn'tpublic boolean Enabled()
true
indicates that the sensor generates events,
false
that it doesn'tpublic void Enabled(boolean enabled)
enabled
- true
enables sensor event generation,
false
disables itpublic float Pitch()
To return meaningful values the sensor must be enabled.
public float Roll()
To return meaningful values the sensor must be enabled.
public float Azimuth()
To return meaningful values the sensor must be enabled.
public float Angle()
Angle property getter method (read-only property). Specifically, this
provides the angle in which the orientation sensor is tilted, treating
-Roll()
as the x-coordinate and Pitch()
as the
y-coordinate. For the amount of the tilt, use Magnitude()
.
To return meaningful values the sensor must be enabled.
public float Magnitude()
Angle()
.
To return meaningful values the sensor must be enabled.
public void onSensorChanged(android.hardware.SensorEvent sensorEvent)
onSensorChanged
in interface android.hardware.SensorEventListener
sensorEvent
- an event from the accelerometer or magnetic field sensorpublic void onAccuracyChanged(android.hardware.Sensor sensor, int accuracy)
onAccuracyChanged
in interface android.hardware.SensorEventListener
public void onDelete()
onDelete
in interface Deleteable
public void onPause()
onPause
in interface OnPauseListener
public void onResume()
onResume
in interface OnResumeListener