title: how to getRotationMatrix having only accelerometer sensor in device
body: <p>I want to get device rotation and i have achieved somehow but the code is not working which device is not present with Magentic sensor,Orientation sensor and Gyroscope sensor. But i have seen some app those are working like <a href="https://play.google.com/store/apps/details?id=com.plaincode.clinometer&amp;hl=en" rel="nofollow">XClinometer</a> and <a href="https://play.google.com/store/apps/details?id=com.ihandysoft.carpenter.level&amp;feature=search_result#?t=W251bGwsMSwxLDEsImNvbS5paGFuZHlzb2Z0LmNhcnBlbnRlci5sZXZlbCJd" rel="nofollow">iHandy level free</a> on device .Having device htc Explorer not giving value as not present with these sensor.please tell me how i can achieve this task.
  I have use this code but as sensor not available so not getting any value so no rotation matrix as well.</p>
  
  <pre><code>  @Override
      public void onSensorChanged(SensorEvent event) {
  
          switch (event.sensor.getType()) {
          case Sensor.TYPE_ACCELEROMETER:
              // copy new accelerometer data into accel array and calculate
              // orientation
              System.arraycopy(event.values, 0, accel, 0, 3);
              calculateAccMagOrientation();
              break;
  
          case Sensor.TYPE_GYROSCOPE:
              // process gyro data
              gyroFunction(event);
              break;
  
          case Sensor.TYPE_MAGNETIC_FIELD:
              // copy new magnetometer data into magnet array
              System.arraycopy(event.values, 0, magnet, 0, 3);
              break;
  
          }
  </code></pre>
  
  <p>}</p>
  
  <p>and the method is</p>
  
  <pre><code>public void calculateAccMagOrientation() {
  
           if (SensorManager.getRotationMatrix(rotationMatrix, null, accel,
                  magnet)) {
              SensorManager.remapCoordinateSystem(rotationMatrix, SensorManager.AXIS_X,
                      SensorManager.AXIS_Y, mValuesOrientation);
              SensorManager.getOrientation(rotationMatrix, mValuesOrientation);
  
          }else{
              //float[] array = new float[9];
              if(magnet[0]&lt;=0){
                  System.out.println("herr.....");
                  System.out.println();
              }else{
                  System.out.println("null so herr.....");
              }
              /*on htc device it is coming here so i need code here to get angle as only received accelerometer sensor data.
             */
          }
      }
  </code></pre>