Thank you Mark,

Yes, I just take out from my table my USB black hole, but still not
working. I was reading on another Thread that the problem might be
because of external influences like music or whatever, but I'm not
playing on my application:

The Thread is:

https://groups.google.com/group/android-developers/browse_thread/thread/5b4ce338d4c57669/c405d018e26683ab#c405d018e26683ab

On the LogCat I'm getting as well the following messages:

12-08 14:02:06.854: DEBUG/SensorManager(13541): found sensor: AK8976A
3-axis Accelerometer, handle=0
12-08 14:02:06.864: DEBUG/SensorManager(13541): found sensor: AK8976A
3-axis Magnetic field sensor, handle=1
12-08 14:02:06.864: DEBUG/SensorManager(13541): found sensor: AK8976A
Orientation sensor, handle=2
12-08 14:02:06.864: DEBUG/SensorManager(13541): found sensor: AK8976A
Temperature sensor, handle=3
12-08 14:02:06.884: DEBUG/Sensors(75): sensors=00000001, real=00000001
12-08 14:02:06.884: DEBUG/AKMD(56): Compass OPEN

Last one make me fill uncomfortable. Am I really using the Compass? :S

On 8 Dez., 13:41, "Mark Murphy" <[email protected]> wrote:
> > Hello all,
>
> > I'm using a HTC Magic in order to develop an application which makes
> > use of the accelerometer. Following the indications from tutorials and
> > the docs, this is a snapshot of the code I'm using:
>
> > /* Next code register the ACCELEROMETER SENSOR*/
> >   SensorManager mSensorManager = (SensorManager) getSystemService
> > (Context.SENSOR_SERVICE);
>
> >   List<Sensor> listSensors = mSensorManager.getSensorList
> > (Sensor.TYPE_ACCELEROMETER);
> >   Sensor acelerometerSensor = listSensors.get(0);
> >   mSensorManager.registerListener(this, acelerometerSensor,
> > SensorManager.SENSOR_DELAY_UI);
>
> > /*OnSensorChanged Method, here I receive the wrong values*/
> > public void onSensorChanged(SensorEvent event) {
> >            // TODO Auto-generated method stub
> >            synchronized (this) {
> >                      switch(event.sensor.getType()) {
> >                                     case Sensor.TYPE_ACCELEROMETER:
> >                                       for (int i=0 ; i<3 ; i++) {
> >                                              mAccelerometerValues[i] =
> > event.values[i];
> >                                       }
> >                     if ( mAccelerometerValues[0]  >= 1)
> >                                   //selectAndChange() send some HTTP
> > Petitions and updates the screen
> >                             selectAndChange(0, null,"",3);
> >                     else if ( mAccelerometerValues[0]  <= -1)
>
> >                                      [...]
>
> >                            default:
> >                      }
>
> >              }
> > }
>
> > I'm nevermind getting values that don't match with the accelerometer.
> > With the phone standing over my table, with no movement, I get values
> > like:
>
> > [0,0,15]
> > [0,6,8]
> > [0,0,0]
>
> > And sometimes the expected value:
> > [0,9.8,0]
>
> > I guess my SensorManager is kind of mixing all the other sensors, but
> > I do not guess where the problem could be. I have been checking other
> > codes, and in all of them the estructure is aproximately the same.
>
> > Any clues of what could I try?
>
> Rather than:
>
> Sensor acelerometerSensor = listSensors.get(0);  
> mSensorManager.registerListener(this, acelerometerSensor,
> SensorManager.SENSOR_DELAY_UI);
>
> try:
>
> mSensorManager.registerListener(this,
> mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
> SensorManager.SENSOR_DELAY_UI);
>
> This may not help, but it is safer code than just assuming get(0) will
> give you the best accelerometer.
>
> Also, have you checked around your table for a black hole, neutron star,
> or any other strong gravitational source that might affect your readings?
> :-)
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com
> Android App Developer Books:http://commonsware.com/books.html

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