I'm developing a compass for Android OS. When I use TYPE_MAGNETIC_FIELD, some devices have this sensor, some devices don't. I don't know how to handle this problem. Should I not support these devices or use another sensor approach. Can you give me an advice?
if (event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) {
Log.d(TAG+" Magentic", String.valueOf(event.values[0]));
mGeomagnetic[0] = mGeomagnetic[0] + alpha_mag*(event.values[0]-mGeomagnetic[0]);
mGeomagnetic[1] = mGeomagnetic[1] + alpha_mag*(event.values[1]-mGeomagnetic[1]);
mGeomagnetic[2] = mGeomagnetic[2] + alpha_mag*(event.values[2]-mGeomagnetic[2]);
}
Thank you very much.
handle it with an if statement ?