title: Why I need to shake my phone to get the correct "Compass-Data"?
body: <p>I have a little problem with the "Compass".</p>
  
  <p>I want to show  on the screen in which direction I am looking with the camera.
  For that I have a <code>CameraView</code> and an <code>Activity</code> in running in landscape mode.</p>
  
  <p>Now I try to get the direction with the sensors but something went wrong. When I start the app it shows some strange data but after shaking my phone it shows the correct data?!</p>
  
  <p>Maybe you can help me. This is my onSensorChanged method:</p>
  
  <pre><code>public void onSensorChanged(SensorEvent event) {
  
      int type = event.sensor.getType();
      if (type == Sensor.TYPE_ACCELEROMETER) {
          mGrav = event.values.clone();
      } else if (type == Sensor.TYPE_MAGNETIC_FIELD) {
          mMag = event.values.clone();
      }
  
      if (SensorManager.getRotationMatrix(mRinn, null, mGrav, mMag)) {
          SensorManager.remapCoordinateSystem(mRinn, SensorManager.AXIS_X, SensorManager.AXIS_Z, mRout);
  
          SensorManager.getOrientation(mRout, mOrient);
  
          //Logger.d("direction?: " + Math.toDegrees(mOrient[0]));
          setOrientationText(Math.toDegrees(mOrient[0]));
      }
  }
  </code></pre>
  
  <p>I am getting the data of the two sensors (magnet and accelerator) and then creating the RotationMatrix (like the documentation told me). In case it is landscape I put X -> X Axis and Y -> Z Axis for the RotationMatrix.</p>
  
  <p>The screenOrientation for this Activity is landscape, too.</p>
  
  <p>But I really don't understand why I am getting the correct data only after shaking the phone?!</p>