public class CategoryOrientationAgent extends SensorAgent<CategoryOrientation,CategoryOrientationData,ICategoryOrientationDataCallback>
SensorAgent and manages orientation sensors on hardware devices.
This class is used to obtain all orientation sensors, a type of sensors in the orientation sensor category, and the first sensor of a specific type, and set or release the sensor data callback.
When you need to obtain information such as an orientation, a rotation vector, and screen rotation, you can call this class to obtain a specific sensor and set the sensor data callback. You can also release the sensor data callback when the sensor data is unneeded.
SensorBase,
SensorAgent,
CategoryOrientation,
CategoryOrientationData,
ICategoryOrientationDataCallbackSystemCapability.Sensors#SENSORSENSOR_CATEGORY_BODY, SENSOR_CATEGORY_DEVICEMOTION, SENSOR_CATEGORY_ENVIRONMENT, SENSOR_CATEGORY_LIGHT, SENSOR_CATEGORY_ORIENTATION, SENSOR_CATEGORY_OTHER, SENSOR_SAMPLING_RATE_FASTEST, SENSOR_SAMPLING_RATE_GAME, SENSOR_SAMPLING_RATE_NORMAL, SENSOR_SAMPLING_RATE_UI, STRING_SENSOR_CATEGORY_BODY, STRING_SENSOR_CATEGORY_DEVICEMOTION, STRING_SENSOR_CATEGORY_ENVIRONMENT, STRING_SENSOR_CATEGORY_LIGHT, STRING_SENSOR_CATEGORY_ORIENTATION, STRING_SENSOR_CATEGORY_OTHER| 构造器 | 说明 |
|---|---|
CategoryOrientationAgent() |
Default constructor used to create a
CategoryOrientationAgent instance. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
List<CategoryOrientation> |
getAllSensors() |
Obtains all orientation sensors.
|
List<CategoryOrientation> |
getAllSensors(int sensorType) |
Obtains a specified type of sensors in the orientation category.
|
CategoryOrientation |
getSingleSensor(int sensorType) |
Obtains the default sensor of a specified type in the orientation category.
|
boolean |
releaseSensorDataCallback(ICategoryOrientationDataCallback callback) |
Releases the callback for all orientation sensors.
|
boolean |
releaseSensorDataCallback(ICategoryOrientationDataCallback callback,
CategoryOrientation sensor) |
Releases the callback for an orientation sensor.
|
boolean |
setSensorDataCallback(ICategoryOrientationDataCallback callback,
CategoryOrientation sensor,
int mode) |
Sets a callback for an orientation sensor to receive sensor data in a specified sampling
mode.
|
boolean |
setSensorDataCallback(ICategoryOrientationDataCallback callback,
CategoryOrientation sensor,
int mode,
long maxDelay) |
Sets a callback for an orientation sensor to receive sensor data in a specified sampling
mode based on the maximum event reporting latency.
|
boolean |
setSensorDataCallback(ICategoryOrientationDataCallback callback,
CategoryOrientation sensor,
long interval) |
Sets a callback for an orientation sensor to receive the sensor data at a specified
sampling interval.
|
boolean |
setSensorDataCallback(ICategoryOrientationDataCallback callback,
CategoryOrientation sensor,
long interval,
long maxDelay) |
Sets a callback for an orientation sensor to receive the sensor data at a specified
sampling interval based on the maximum event reporting latency.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetSensorMinSampleInterval, runCommand, subscribeParamsCheckpublic CategoryOrientationAgent()
CategoryOrientationAgent instance.public List<CategoryOrientation> getAllSensors()
Orientation sensors include the six degrees of freedom (6DoF) sensors, screen rotation sensors, device orientation sensors, orientation type sensors, rotation vector sensors, game rotation vector sensors, and geomagnetic rotation vector sensors.
getAllSensors 在类中 SensorAgent<CategoryOrientation,CategoryOrientationData,ICategoryOrientationDataCallback>getAllSensors(int),
getSingleSensor(int),
CategoryOrientationpublic List<CategoryOrientation> getAllSensors(int sensorType)
getAllSensors 在类中 SensorAgent<CategoryOrientation,CategoryOrientationData,ICategoryOrientationDataCallback>sensorType - Indicates a sensor type in the orientation category.
CategoryOrientation defines the sensor types using integer
constants. For example, you can set CategoryOrientation.SENSOR_TYPE_ORIENTATION
for this parameter to obtain orientation type sensors.getAllSensors(),
getSingleSensor(int),
CategoryOrientationpublic CategoryOrientation getSingleSensor(int sensorType)
The default sensor is the first sensor of a specified type in the orientation category.
getSingleSensor 在类中 SensorAgent<CategoryOrientation,CategoryOrientationData,ICategoryOrientationDataCallback>sensorType - Indicates a sensor type in the orientation category.
CategoryOrientation defines the sensor types using integer
constants. For example, you can set CategoryOrientation.SENSOR_TYPE_ORIENTATION
for this parameter to obtain orientation type sensors.null if the specified sensor
type does not exist.getAllSensors(),
getAllSensors(int),
CategoryOrientationpublic boolean setSensorDataCallback(ICategoryOrientationDataCallback callback, CategoryOrientation sensor, long interval)
callback - Indicates the callback
ICategoryOrientationDataCallback to set for receiving
orientation sensor data. If this parameter is null, setting the callback fails.sensor - Indicates the sensor for which the callback is to be set. If this parameter
is null, setting the callback fails.interval - Indicates the sampling interval, in nanoseconds. The sampling interval may
vary depending on the sensor type. You can use the
SensorBase.getMinInterval() and
SensorBase.getMaxInterval() methods to obtain the minimum
sampling interval and maximum sampling interval of the sensor, respectively, and then set
the value of this parameter in between. If the configured parameter value is smaller than
the minimum sampling interval of the sensor, the minimum sampling interval is used. If the
configured parameter value is larger than the maximum sampling interval of the sensor, the
maximum sampling interval is used.true if the callback is set successfully; returns false
otherwise.setSensorDataCallback(ICategoryOrientationDataCallback, CategoryOrientation, long, long),
ICategoryOrientationDataCallback,
CategoryOrientationpublic boolean setSensorDataCallback(ICategoryOrientationDataCallback callback, CategoryOrientation sensor, long interval, long maxDelay)
setSensorDataCallback 在类中 SensorAgent<CategoryOrientation,CategoryOrientationData,ICategoryOrientationDataCallback>callback - Indicates the callback
ICategoryOrientationDataCallback to set for receiving
orientation sensor data. If this parameter is null, setting the callback fails.sensor - Indicates the sensor for which the callback is to be set. If this parameter
is null, setting the callback fails.interval - Indicates the sampling interval, in nanoseconds. The sampling interval may
vary depending on the sensor type. You can use the
SensorBase.getMinInterval() and
SensorBase.getMaxInterval() methods to obtain the minimum
sampling interval and maximum sampling interval of the sensor, respectively, and then set
the value of this parameter in between. If the configured parameter value is smaller than
the minimum sampling interval of the sensor, the minimum sampling interval is used. If the
configured parameter value is larger than the maximum sampling interval of the sensor, the
maximum sampling interval is used.maxDelay - Indicates the maximum latency for the sensor to report events to the
application in nanoseconds, based on the first in first out (FIFO) policy of the hardware.
The maximum latency may vary depending on the sensor.true if the callback is set successfully; returns false
otherwise.ICategoryOrientationDataCallback,
CategoryOrientationpublic boolean setSensorDataCallback(ICategoryOrientationDataCallback callback, CategoryOrientation sensor, int mode)
setSensorDataCallback 在类中 SensorAgent<CategoryOrientation,CategoryOrientationData,ICategoryOrientationDataCallback>callback - Indicates the callback
ICategoryOrientationDataCallback to set for receiving
orientation sensor data. If this parameter is null, setting the callback fails.sensor - Indicates the sensor for which the callback is to be set. If this parameter
is null, setting the callback fails.mode - Indicates the sampling mode. Each sampling mode represents a sampling rate,
including the fastest sampling rate, sampling rate in gaming scenarios, sampling rate on
UIs, and default sampling rate. For example, you can set the fastest sampling rate of the
sensor via SensorAgent#SENSOR_SAMPLING_RATE_FASTEST.true if the callback is set successfully; returns false
otherwise.public boolean setSensorDataCallback(ICategoryOrientationDataCallback callback, CategoryOrientation sensor, int mode, long maxDelay)
setSensorDataCallback 在类中 SensorAgent<CategoryOrientation,CategoryOrientationData,ICategoryOrientationDataCallback>callback - Indicates the callback
ICategoryOrientationDataCallback to set for receiving
orientation sensor data. If this parameter is null, setting the callback fails.sensor - Indicates the sensor for which the callback is to be set. If this parameter
is null, setting the callback fails.mode - Indicates the sampling mode. Each sampling mode represents a sampling rate,
including the fastest sampling rate, sampling rate in gaming scenarios, sampling rate on
UIs, and default sampling rate. For example, you can set the fastest sampling rate of the
sensor via SensorAgent#SENSOR_SAMPLING_RATE_FASTEST.maxDelay - Indicates the maximum latency (in nanoseconds) for the sensor to report
events to the application, based on the first in first out (FIFO) policy of the hardware.
The maximum latency may vary depending on the sensor.true if the callback is set successfully; returns false
otherwise.public boolean releaseSensorDataCallback(ICategoryOrientationDataCallback callback, CategoryOrientation sensor)
releaseSensorDataCallback 在类中 SensorAgent<CategoryOrientation,CategoryOrientationData,ICategoryOrientationDataCallback>callback - Indicates the callback
ICategoryOrientationDataCallback set for receiving
orientation sensor data. If this parameter is null, releasing the callback fails.sensor - Indicates the sensor for which the callback is to be released. If this
parameter is null, the callback of all orientation sensors will be released.true if the callback is released successfully; returns false
otherwise.ICategoryOrientationDataCallback,
CategoryOrientationpublic boolean releaseSensorDataCallback(ICategoryOrientationDataCallback callback)
releaseSensorDataCallback 在类中 SensorAgent<CategoryOrientation,CategoryOrientationData,ICategoryOrientationDataCallback>callback - Indicates the callback
ICategoryOrientationDataCallback set for receiving
orientation sensor data. If this parameter is null, releasing the callback fails.true if the callback is released successfully; returns false
otherwise.ICategoryOrientationDataCallback