Hello everyone,
I have a problem registering a new Sensor Listener with the new SDK.
Most of the code examples ive been reading are made with the old
interface SensorListener that is now deprecated. We should use
SensorEventListener now, and new methods with new signature like
registerListener.
The new signature is
registerListener(SensorEventListener listener, Sensor sensor, int
rate);
But the only ways ive found to get a Sensor is by using the methods
SensorManager.getSensorList(int numberIndex) that returns a list of
sensors or the getDefaultSensor(int typeOfSensor) that returns
something weird (that could be the sensor you passes in parameter but
i dont really now to be honest).
So here is what ive been writting:
protected void onResume()
{
super.onResume();
sensorManager.registerListener(this,
sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION),
SensorManager.SENSOR_DELAY_FASTEST);
}
this ain't working, everything seems great until i launch the app and
get a proper "your appplication will be closed"
so ive tried useing the getSensorList:
protected void onResume()
{
super.onResume();
sensorManager.registerListener(this, sensorManager.getSensorList
(Sensor.TYPE_ORIENTATION).get(0), SensorManager.SENSOR_DELAY_FASTEST);
}
considering the list starts at 0, i just choose to pick the first
element (I have no clue what's on the list).
Again, it ain't working...
Does anyone have a clue on how to register a listener properly with
the new SDK?
that would help me a LOT!
cheers,
Qlabs
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---