( edit: I added the best working approach in my augmented reality framework and now also take the gyroscope into account which makes it much more stable again: Droid
Check out the Sensor fusion demo app which uses different sensors (gyroscope, rotation-vector, accelerometer + compass, etc.) and renders the outputs from the onSensorChanged-events as a coloured cube that rotates accordingly to your phone.
The results from those events are stored as quaternions and rotation matrices and used in this class which OpenGL.