문제

I want to write an app for the Samsung S-View cover. To find out if the cover is closed I want to use the magnet which is in the cover and not the light sensor. I tried for my own with the deafult Android magnetic API:

SensorManager manager = (SensorManager) getSystemService(SENSOR_SERVICE);
Sensor s = manager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
manager.registerListener(this, s, SensorManager.SENSOR_DELAY_NORMAL);

tv.setText(event.values[2]);

but I do not know how to interpret the numbers. Of course I tried with the x-axis and y-axis too. They depends on the axis how I hold my phone and there is not a big difference if I have the Flip cover behind or in front of my phone. Do you have any ideas how I can find out if the cover is in front of my phone using the magnetic sensor? Do I have to use the uncalibrated sensor or did I do something else wrong?

도움이 되었습니까?

해결책

I do believe this feature is made by the magnetic sersor, available in standard android API. Anyway, run an experiment with the smart cover to see if you can use that data.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top