title: Android accelerometer detect device lying still
body: <p>I am developing an application for Android that is supposed to check whether the device is lying still. This has to work when i lay the device on a flat surface. <strong>This also has to work when the device is lying still on either side of the device.</strong> While I am holding the device very still in my hand the check should fail. Because the small movement from your hand/arm should be enough to detect movement.</p>
  
  <p>I've tried this over and over but i still seem to fail in doing so. What usually happens is that the data i receive from the <code>SensorEventListener</code> is always fluctuating heavily. The data below represents the data i get back from the device while lying still on a flat surface.</p>
  
  <pre><code>0.07366191
  0.056904275
  0.034122672
  0.047471035
  0.080519415
  0.07816742
  1.2434766
  0.34602648
  0.25965866
  0.52344894
  0.14806636
  </code></pre>
  
  <p>I've tried the following:</p>
  
  <ul>
  <li>10 second calibrate while lying flat on the table, storing that calibrated value and use it as threshold.</li>
  <li>Fixed thresholding based on <code>Math.sqrt(ax * ax + ay * ay + az * az)</code> results.</li>
  <li>Using either the <code>TYPE_LINEAR_ACCELERATION</code> or normal type.</li>
  <li>Using gravity (9.8) as threshold.</li>
  </ul>
  
  <p>At this point I don't really know what to do anymore. I really hope someone can help me out. Thanks in advance.</p>