title: First Android App - How to Access the Compass
body: <p>I'm making my first Android application.  As a toy problem to learn the system I want to make a simple app that display as text which direction the phone is pointing using the built in compass.</p>
  
  <p>How do I access the compass from my code, and have my code be aware of direction changes?</p>
  
  <p>I believe I'll need the <a href="http://developer.android.com/reference/android/hardware/SensorManager.html" rel="nofollow noreferrer">SensorManager class</a> but I'm confused how to use it.  How do I tell it I want the compass sensor?  How do I tell it to do an action (update text) on a direction change?</p>