Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

S-View cover detection [magnetic sensor]

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?

like image 969
Cilenco Avatar asked May 13 '14 21:05

Cilenco


1 Answers

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.

like image 61
Dmitry Gryazin Avatar answered Sep 26 '22 08:09

Dmitry Gryazin