We recently released an Android port of an iPhone app. The app relies on the digital compass for some features. This has been working well on most devices, but there are a few where the compass is not working. It seems the device is not feeding us any onSensorChanged() messages after we register to receive them.
I think all the problems are with devices running Android 2.2 They users claim that other apps that make use of the compass work just fine for them. We start the compass using: if ( magnetometer != null && accelerometer != null ) { if ( compassOn ) { sensorManager.registerListener( this, accelerometer, (int) (1000000 / kSensorUpdateFrequencyFast) ); sensorManager.registerListener( this, magnetometer, (int) (1000000 / kSensorUpdateFrequencyFast) ); } else { sensorManager.registerListener( this, accelerometer, (int) (1000000 / kSensorUpdateFrequencySlow) ); sensorManager.registerListener( this, magnetometer, (int) (1000000 / kSensorUpdateFrequencySlow) ); } } Where the magnetometer and accelerometer are initialized at program startup using: sensorManager = (SensorManager) getSystemService( SENSOR_SERVICE ); accelerometer = sensorManager.getDefaultSensor( Sensor.TYPE_ACCELEROMETER ); magnetometer = sensorManager.getDefaultSensor( Sensor.TYPE_MAGNETIC_FIELD ); We do get a valid (non-null) accelerometer and magnetometer sensors returned from these calls. So does anyone have any thoughts on why the compass code might not be working on those 2.2 devices? I see that even the Compass example in the example code with the Android SDK still used the deprecated ORIENTATION sensor for getting compass values. Is this what should be used on 2.2? -- Bill Tschumy Otherwise -- Longmont, CO http://www.otherwise.com -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en