title: Programmatically disable the screen on/off magnetic sensor on Android
body: <p>Several Android devices famously the Nexus series have a magnetic sensor that is NOT the <code>android.hardware.Sensor.TYPE_MAGNETIC_FIELD</code> used exclusively to turn the screen ON/OFF automatically using phone cases that have a small magnet inside them.</p>
  
  <p>On my application, I'm using magnet detection using <code>android.hardware.Sensor.TYPE_MAGNETIC_FIELD</code> and the <code>SensorManager</code> to detect user touches the phone in a case with some magnets inside.</p>
  
  <p>The code works without issues, the problem is that it's extremely easy on those devices to accidentally trigger the screen ON/OFF sensor thou, turning off the screen.</p>
  
  <p>I've tried:</p>
  
  <ul>
  <li><code>android:keepScreenOn="true"</code> on the XML</li>
  <li>using the permission <code>android.permission.WAKE_LOCK</code> and acquiring a wake-lock via <code>PowerManager</code>.</li>
  </ul>
  
  <p>Both without success.</p>
  
  <p>Is there a way to temporarily disable this sensor while my activity is resumed?</p>