title: getting angle using gyroscope in android
body: <p>Can I calculate the angle from gyroscope with this code? I mean is the calculation of dT correct? </p>
  
  <pre><code>public void onSensorChanged(SensorEvent event) {
              switch (event.sensor.getType()) {
        /* Other sensor cases */
             case Sensor.TYPE_GYROSCOPE: 
              for (int j=0;j&lt;3;j++) mGyro[j] = event.values[j];
              if(i==0)
                  i=1;
              else
                  i=2;
              if(i==1)
                  start=System.nanoTime();
                  else if(i==2) {
                      finish=System.nanoTime();
                   dT=( finish-start )/1000000000f;
                               i=0;
                  }
  
              angle[0]=(float) ((angle[0]+mGyro[0]*dT)*180/3.1428f);
              angle[1]=(float) ((angle[1]+mGyro[0]*dT)*180/3.1428f);
              angle[2]=(float) ((angle[2]+mGyro[0]*dT)*180/3.1428f);
  
              break;
  </code></pre>