public class CategoryOtherAgent extends SensorAgent<CategoryOther,CategoryOtherData,ICategoryOtherDataCallback>
SensorAgent and manages sensors in the other category (a category other
than motion, environment, orientation, and light) on hardware devices.
This class is used to obtain sensors in the other category, a type of sensors in that 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 a grip detector, magnet bracket, and pressure detector, 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,
CategoryOther,
CategoryOtherData,
ICategoryOtherDataCallbackSystemCapability.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| 构造器 | 说明 |
|---|---|
CategoryOtherAgent() |
Default constructor used to create a
CategoryOtherAgent instance. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
List<CategoryOther> |
getAllSensors() |
Obtains all sensors in the other category.
|
List<CategoryOther> |
getAllSensors(int sensorType) |
Obtains a specified type of sensors in the other category.
|
CategoryOther |
getSingleSensor(int sensorType) |
Obtains the default sensor of a specified type in the other category.
|
boolean |
releaseSensorDataCallback(ICategoryOtherDataCallback callback) |
Releases the callback for all sensors in the other category.
|
boolean |
releaseSensorDataCallback(ICategoryOtherDataCallback callback,
CategoryOther sensor) |
Releases the callback for a sensor in the other category.
|
boolean |
setSensorDataCallback(ICategoryOtherDataCallback callback,
CategoryOther sensor,
int mode) |
Sets a callback for a sensor in the other category to receive sensor data in a specified
sampling mode.
|
boolean |
setSensorDataCallback(ICategoryOtherDataCallback callback,
CategoryOther sensor,
int mode,
long maxDelay) |
Sets a callback for a sensor in the other category to receive sensor data in a specified
sampling mode based on the maximum event reporting latency.
|
boolean |
setSensorDataCallback(ICategoryOtherDataCallback callback,
CategoryOther sensor,
long interval) |
Sets a callback for a sensor in the other category to receive the sensor data at a
specified sampling interval.
|
boolean |
setSensorDataCallback(ICategoryOtherDataCallback callback,
CategoryOther sensor,
long interval,
long maxDelay) |
Sets a callback for a sensor in the other category 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 CategoryOtherAgent()
CategoryOtherAgent instance.public List<CategoryOther> getAllSensors()
Sensors in the other category include Hall effect sensors, grip detection sensors, magnet bracket sensors, and pressure detection sensors.
getAllSensors 在类中 SensorAgent<CategoryOther,CategoryOtherData,ICategoryOtherDataCallback>getAllSensors(int),
getSingleSensor(int),
CategoryOtherpublic List<CategoryOther> getAllSensors(int sensorType)
getAllSensors 在类中 SensorAgent<CategoryOther,CategoryOtherData,ICategoryOtherDataCallback>sensorType - Indicates a sensor type in the other category.
CategoryOther defines the sensor types using integer
constants. For example, you can set CategoryOther.SENSOR_TYPE_HALL for this
parameter to obtain Hall effect sensors.getAllSensors(),
getSingleSensor(int),
CategoryOtherpublic CategoryOther getSingleSensor(int sensorType)
The default sensor is the first sensor of a specified type in the other category.
getSingleSensor 在类中 SensorAgent<CategoryOther,CategoryOtherData,ICategoryOtherDataCallback>sensorType - Indicates a sensor type in the other category.
CategoryOther defines the sensor types using integer
constants. For example, you can set CategoryOther.SENSOR_TYPE_HALL for this
parameter to obtain Hall effect sensors.null if the specified sensor type
does not exist.getAllSensors(),
getAllSensors(int),
CategoryOtherpublic boolean setSensorDataCallback(ICategoryOtherDataCallback callback, CategoryOther sensor, long interval)
callback - Indicates the callback
ICategoryOtherDataCallback to set for receiving sensor
data in the other category. 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(ICategoryOtherDataCallback, CategoryOther, long, long),
ICategoryOtherDataCallback,
CategoryOtherpublic boolean setSensorDataCallback(ICategoryOtherDataCallback callback, CategoryOther sensor, long interval, long maxDelay)
setSensorDataCallback 在类中 SensorAgent<CategoryOther,CategoryOtherData,ICategoryOtherDataCallback>callback - Indicates the callback
ICategoryOtherDataCallback to set for receiving sensor
data in the other category. 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.ICategoryOtherDataCallback,
CategoryOtherpublic boolean setSensorDataCallback(ICategoryOtherDataCallback callback, CategoryOther sensor, int mode)
setSensorDataCallback 在类中 SensorAgent<CategoryOther,CategoryOtherData,ICategoryOtherDataCallback>callback - Indicates the callback
ICategoryOtherDataCallback to set for receiving sensor data
in the other category. 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(ICategoryOtherDataCallback callback, CategoryOther sensor, int mode, long maxDelay)
setSensorDataCallback 在类中 SensorAgent<CategoryOther,CategoryOtherData,ICategoryOtherDataCallback>callback - Indicates the callback
ICategoryOtherDataCallback to set for receiving sensor data
in the other category. 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(ICategoryOtherDataCallback callback, CategoryOther sensor)
releaseSensorDataCallback 在类中 SensorAgent<CategoryOther,CategoryOtherData,ICategoryOtherDataCallback>callback - Indicates the callback
ICategoryOtherDataCallback set for receiving sensor data
in the other category. 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 sensors in the other category will be released.true if the callback is released successfully; returns false
otherwise.ICategoryOtherDataCallback,
CategoryOtherpublic boolean releaseSensorDataCallback(ICategoryOtherDataCallback callback)
releaseSensorDataCallback 在类中 SensorAgent<CategoryOther,CategoryOtherData,ICategoryOtherDataCallback>callback - Indicates the callback
ICategoryOtherDataCallback set for receiving sensor data
in the other category. If this parameter is null, releasing the callback fails.true if the callback is released successfully; returns false
otherwise.ICategoryOtherDataCallback