well the new signature of the registerListener is a bit tricky coz the
only way to get a Sensor is by using the method getSensorList or
getDefaultSensor. Ive been using both and i can't suceed registering
the listener and i always get an error when i launch the program.
here are what im trying to overload:

sensorManager.registerListener(this, sensorManager.getSensorList
(Sensor.TYPE_ORIENTATION).get(0), SensorManager.SENSOR_DELAY_FASTEST);

or

sensorManager.registerListener(this, sensorManager.getDefaultSensor
(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_FASTEST);

any idea why it's not working?


On 11 mai, 19:34, Todd Sjolander <[email protected]> wrote:
> Your MyListener class is correct.  The problem is in your call 
> toregisterListener().  That's an overloaded method.  The one you're
> calling is the old one that still takes the deprecated class.  Here's
> the new signature:
>
> registerListener(SensorEventListener listener, Sensor sensor, int
> rate, Handler handler);
>
> On May 7, 11:00 am, doubleslash <[email protected]> wrote:
>
> > I recently installed SDK 1.5 and updated the Eclipse adt to 0.9. I
> > tried using the accelerometer sensor but kept getting an error when
> > registerring the listener. My code is as follows:
>
> > class myActivity extends Activity{
>
> > SensorManager sm  = (SensorManager)getSystemService
> > (Context.SENSOR_SERVICE);
> > sm.registerListener(new MyListener(), Sensor.TYPE_ACCELEROMETER,
> > SensorManager.SENSOR_DELAY_UI);
>
> > class MyListener implements SensorEventListener{
> > // implementation is irrelevant
>
> > }
> > }
>
> > I keep getting the error that I should change MyListener to type
> > SensorListener, which has  been replaced by SensorEventListener in the
> > new SDK.
>
> > I chose to compile my code against Android 1.5. It seems that I have
> > successfully set up the new SDK as it can find the new interface
> > SensorEventListener. Why doesregisterListenerrequire an interface
> > that has been deprecated?

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to