title: Is there a stable way to detect shaking event?
body: <p>I've tried to detect shaking event using accelerometer.
  I've found that when I give a contiuous shake to the phone, the value difference
  of the acceleration is quite stable.
  But when I rotate the phone, there's always a big change on the value( the value is usually bigger than  "shaking without rotation").
  I want to focus on the shaking event, not the rotation event. Is there a way to solve 
  the problem?</p>
  
  <p>here's my code for shaing detection</p>
  
  <pre><code>public void onSensorChanged(SensorEvent event)
      {
          if (event.sensor.getType() == SensorManager.SENSOR_ACCELEROMETER)
          {
              nowTime = System.currentTimeMillis();
  
              float x = event.values[SensorManager.DATA_X];
              float y = event.values[SensorManager.DATA_Y];
              float z = event.values[SensorManager.DATA_Z];
              nowAcc = Math.sqrt(x*x+y*y+z*z);
              accDiff = Math.abs(nowAcc - preAcc);
              timeDiff = (nowTime - preTime);
                          //  try to get the sum of 10 samplings of accDiff
              tempAccDiff10 = tempAccDiff9;
              tempAccDiff9 = tempAccDiff8;
              tempAccDiff8 = tempAccDiff7;
              tempAccDiff7 = tempAccDiff6;
              tempAccDiff6 = tempAccDiff5;
              tempAccDiff5 = tempAccDiff4;
              tempAccDiff4 = tempAccDiff3;
              tempAccDiff3 = tempAccDiff2;
              tempAccDiff2 = tempAccDiff1;
              tempAccDiff1 = accDiff;
              sumAcc = tempAccDiff10+tempAccDiff9+tempAccDiff8+tempAccDiff7+tempAccDiff6+
                       tempAccDiff5+tempAccDiff4+tempAccDiff3+tempAccDiff2+tempAccDiff1;
              Log.i("SSSS",String.valueOf(sumAcc));
                          //when I give the phone a big &amp; continuous "shake", it returns
                          //a value about 30~40, but when I give the phone a small
                          //"rotation", it returns a value of 80~120
              preAcc = nowAcc;
              preTime = nowTime;
              if (sumAcc&gt;100)
              {
                  SM.unregisterListener(sensorListener, sensor);
              }
  
              //123
          }
  
  
      }//end of onSensorChanged();
  </code></pre>
  
  <p>is it possible to neglect the rotation event using accelerometer?
  Or should I try to get the orientation change and do some computations 
  on the sumAcc? </p>