title: Implementing current cardinal direction method with TYPE_ROTATION_VECTOR while standing still?
body: <p>There appear to be many old examples of getting the current cardinal direction on Android devices, but an official solution provided by Google does not appear to be in their documentation.</p>
  
  <p>The oldest reference <code>Sensor.TYPE_ORIENTATION</code> which is deprecated, more recent ones mention <code>Sensor.TYPE_ACCELEROMETER</code> and <code>Sensor.TYPE_MAGNETIC_FIELD</code>(which I have tried with little success - accuracy shifts rapidly depending on device orientation). I've been experimenting with implementations using those two like <a href="https://github.com/art2limit/Compass-View/blob/master/app/src/main/java/sky2limit/compassview/lib/CompassSensorManager.java" rel="nofollow noreferrer">this.</a> I've even seen some with <code>TYPE.GRAVITY</code>.</p>
  
  <p>The <a href="https://stackoverflow.com/a/44399837/1238737">most recent seem to suggest</a> <a href="https://developer.android.com/reference/android/hardware/Sensor#TYPE_ROTATION_VECTOR" rel="nofollow noreferrer">TYPE_ROTATION_VECTOR</a> which apparently is a fused sensor(<a href="https://stackoverflow.com/a/42772927/1238737">reference</a>), but example implementations do not seem to be readily available.</p>
  
  <p>I need to use these position/motion sensors, and not GPS, because the user will not be moving during the time when this measurement is needed. Also need the measurement to be stable regardless of whether phone is flat, or vertical(as if you are taking a photo)</p>
  
  <p>After we pull the degree measurement somehow, converting to cardinal direction seems to be the easy part.(<a href="https://stackoverflow.com/a/25349774/1238737">https://stackoverflow.com/a/25349774/1238737</a>)</p>
  
  <p>Previous solutions</p>
  
  <ol>
  <li><a href="https://stackoverflow.com/questions/8315913/how-to-get-direction-in-android-such-as-north-west">How to get Direction in Android (Such as North, West)</a></li>
  <li><a href="https://stackoverflow.com/a/11068878/1238737">https://stackoverflow.com/a/11068878/1238737</a></li>
  </ol>