Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Take a look at the <code>getOrientationUsingGetRotationMatrix()</code> method from <code>DeviceOrientationService</code>: <a href="http://androidxref.com/4.3_r2.1/xref/frameworks/base/core/java/android/webkit/DeviceOrientationService.java" rel="nofollow">Link</a> :</p> <pre><code>private void getOrientationUsingGetRotationMatrix() { if (mGravityVector == null || mMagneticFieldVector == null) { return; } // Get the rotation matrix. // The rotation matrix that transforms from the body frame to the earth frame. float[] deviceRotationMatrix = new float[9]; if (!SensorManager.getRotationMatrix( deviceRotationMatrix, null, mGravityVector, mMagneticFieldVector)) { return; } // Convert rotation matrix to rotation angles. // Assuming that the rotations are appied in the order listed at // http://developer.android.com/reference/android/hardware/SensorEvent.html#values // the rotations are applied about the same axes and in the same order as required by the // API. The only conversions are sign changes as follows. // The angles are in radians float[] rotationAngles = new float[3]; SensorManager.getOrientation(deviceRotationMatrix, rotationAngles); double alpha = Math.toDegrees(-rotationAngles[0]); while (alpha &lt; 0.0) { alpha += 360.0; } // [0, 360) double beta = Math.toDegrees(-rotationAngles[1]); while (beta &lt; -180.0) { beta += 360.0; } // [-180, 180) double gamma = Math.toDegrees(rotationAngles[2]); while (gamma &lt; -90.0) { gamma += 360.0; } // [-90, 90) maybeSendChange(alpha, beta, gamma); } </code></pre> <p>Check if <code>rotation</code> indeed holds valid values and that <code>getRotationMatrix(...)</code> is returning <code>true</code>. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload