After finding the correct SensorInfo
object, you can determine
the sensor URL with the SensorInfo.getUrl
method.
To open a sensor connection, use the javax.microedition.io.Connector.open
method
with the sensor URL as a parameter, for example:
SensorConnection sensorConnection; try { sensorConnection = (SensorConnection)Connector.open(sensorInfo.getUrl()); } catch (IOException e) { // Handle Exception if Connector.open() fails }
The sensor connection can be opened directly without using findSensors
when the sensor URL is known. For maximum
compatibility between different devices and implementations, try to
select the sensor as precisely as possible. For example, on the Symbian
platform, the URL sensor:acceleration
matches
two different versions of the accelerometer: one providing double
values presented in m/s^2 and another providing raw integer values
from the sensor.