title: android: why getrotationmatrix return false?
body: <p>I want to get the orientation of my phone and I have using this code that I find lot of people using it. this is the code</p>
  
  <pre><code>    public void onSensorChanged(SensorEvent event) {
      //if the data sensor is unreliabel
      if(event.accuracy == SensorManager.SENSOR_STATUS_UNRELIABLE)
          return;
  
      //gets the value
      switch (event.sensor.getType()) {
      case Sensor.TYPE_ACCELEROMETER:
          gravity = event.values.clone();
          break;
  
      case Sensor.TYPE_MAGNETIC_FIELD:
          geomag = event.values.clone();
          break;
      }
      getOrientation();
  }
  
  private void getOrientation(){
  
      //if gravity n geomag have value, find the rotation matrix
              if(gravity != null &amp;&amp; geomag != null){
  
                  //check the rotation matrix found
                  boolean success = SensorManager.getRotationMatrix(inR, I, gravity, geomag);
  
                  if(success){
                      SensorManager.getOrientation(inR, orientVals);
                      azimuth = Math.toDegrees(orientVals[0]);
  
                      TextView azi = (TextView) findViewById(R.id.textAzi);
                      azi.setText("azi : " + azimuth);
  
                  }
                  TextView cek = (TextView) findViewById(R.id.cek);
                  cek.setText("rotation: "+success);
              }   
  </code></pre>
  
  <p>but why the getrotationmatrix always return to false?
  where is the problem?</p>