public class AccelerometerSensor extends AndroidNonvisibleComponent implements OnStopListener, OnResumeListener, SensorComponent, android.hardware.SensorEventListener, Deleteable
From the Android documentation: "Sensor values are acceleration in the X, Y and Z axis, where the X axis has positive direction toward the right side of the device, the Y axis has positive direction toward the top of the device and the Z axis has positive direction toward the front of the device. The direction of the force of gravity is indicated by acceleration values in the X, Y and Z axes. The typical case where the device is flat relative to the surface of the Earth appears as -STANDARD_GRAVITY in the Z axis and X and Y values close to zero. Acceleration values are given in SI units (m/s^2)."
formACCELEROMETER_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 |
|---|
AccelerometerSensor(ComponentContainer container)
Creates a new AccelerometerSensor component.
|
| Modifier and Type | Method and Description |
|---|---|
void |
AccelerationChanged(float xAccel,
float yAccel,
float zAccel)
Indicates the acceleration changed in the X, Y, and/or Z dimensions.
|
boolean |
Available()
Available property getter method (read-only property).
|
boolean |
Enabled()
If true, the sensor will generate events.
|
void |
Enabled(boolean enabled)
Specifies whether the sensor should generate events.
|
int |
MinimumInterval()
Returns the minimum interval required between calls to Shaking(),
in milliseconds.
|
void |
MinimumInterval(int interval)
Specifies the minimum interval required between calls to Shaking(),
in milliseconds.
|
void |
onAccuracyChanged(android.hardware.Sensor sensor,
int accuracy) |
void |
onDelete() |
void |
onResume() |
void |
onSensorChanged(android.hardware.SensorEvent sensorEvent) |
void |
onStop() |
int |
Sensitivity()
Returns a number that encodes how sensitive the AccelerometerSensor is.
|
void |
Sensitivity(int sensitivity)
Specifies the sensitivity of the accelerometer
and checks that the argument is a legal value.
|
void |
Shaking()
Indicates the device started being shaken or continues to be shaken.
|
float |
XAccel()
Returns the acceleration in the X-dimension in SI units (m/s^2).
|
float |
YAccel()
Returns the acceleration in the Y-dimension in SI units (m/s^2).
|
float |
ZAccel()
Returns the acceleration in the Z-dimension in SI units (m/s^2).
|
getDispatchDelegateclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetDispatchDelegatepublic AccelerometerSensor(ComponentContainer container)
container - ignored (because this is a non-visible component)public int MinimumInterval()
public void MinimumInterval(int interval)
interval - minimum interval in mspublic int Sensitivity()
public void Sensitivity(int sensitivity)
sensitivity - one of Component.ACCELEROMETER_SENSITIVITY_WEAK,
Component.ACCELEROMETER_SENSITIVITY_MODERATE or
Component.ACCELEROMETER_SENSITIVITY_STRONGpublic void AccelerationChanged(float xAccel,
float yAccel,
float zAccel)
public void Shaking()
public boolean Available()
true indicates that an accelerometer 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 XAccel()
public float YAccel()
public float ZAccel()
public void onSensorChanged(android.hardware.SensorEvent sensorEvent)
onSensorChanged in interface android.hardware.SensorEventListenerpublic void onAccuracyChanged(android.hardware.Sensor sensor,
int accuracy)
onAccuracyChanged in interface android.hardware.SensorEventListenerpublic void onResume()
onResume in interface OnResumeListenerpublic void onStop()
onStop in interface OnStopListenerpublic void onDelete()
onDelete in interface Deleteable