If your Samsung device comes with a magnetic sensor, you can calibrate it.
The first thing that you have to do is go to the Diagnostic Menu by issuing the code *#0*# . Afterwards, go to Sensor. You will know if the magnetic sensor is calibrated or not. See the picture below.