Hello Nathan, I actually use raw Accelerometer + Magnetometer data as
well as the deprecated Orientation sensor in my apps (they support
2.1+) and I have yet to receive anything stating that the orientation
sensor was not available, perhaps I have been lucky. For example
using the Orientation Sensor still works fine on my Honeycomb 3.1
galaxy tab (10.1), and friends 2.2 and 2.3 devices, and I have not
seen any crash reports or gotten any complaints related to it. The
legacy orientation sensor is just a virtual sensor, it's not a
physical hardware component so I don't think there is any trouble with
using it, other than that it may not be as accurate as the non-
deprecated methods, and perhaps there's a performance hit as well
compared to the recommended approach? I've found it works quite
well in certain circumstances where the recommended approach
doesn't.
You can also test for the presence of a particular sensor using the
following:
List<Sensor> sensorList =
mSensorManager.getSensorList(Sensor.TYPE_ORIENTATION);
if (sensorList.size() > 0) {
... // notify user here that they don't have the sensor you want them
to?
}
On Jul 19, 4:19 pm, Nathan <[email protected]> wrote:
> I know there have been some previous posts on this question.
>
> Since Sensor.Type_Orientation has been deprecated, the right thing to
> do is call SensorManager.getOrientation() .
>
> I would note that the API Demos Compass still uses the
> Sensor.Type_Orientation, so it is no help in telling
>
> So far so good: SensorManager.getOrientation() is supported back to
> API level three.
>
> But I do need to register for something so I know when the rotation
> has changed. Although docs don't say *when* something is deprecated,
> I'm assuming this is API level 9.
>
> So should I do this?
>
> if(Versioning.getSDKNumber()<9)
> {
> boolean supported =
> mSensorManager.registerListener(this,
> mSensorManager
>
> .getDefaultSensor(Sensor.TYPE_ORIENTATION),
> SensorManager.SENSOR_DELAY_UI);
> }
> }
>
> else
> {
> boolean supported =
> mSensorManager.registerListener(this,
> mSensorManager
>
> .getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR),
> SensorManager.SENSOR_DELAY_UI);
>
> }
>
> Or is it somehow more complicated?
>
> I'm extra concerned because it appears, based on my error reports in
> console, that some devices fail when I call
> registerListener with Sensor.TYPE_ORIENTATION. They don't return
> false, they don't return an exception.
>
> I don't know what devices they are because the Market Console won't
> tell me. If they are API 9 devices (2.3), the above code will help. If
> they are API 8 devices, then I am a bit stuck, because I can't use
> Sensor.TYPE_ORIENTATION nor Sensor.TYPE_ROTATION_VECTOR.
>
> Nathan
--
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