While working on an internship I had to connect a rotary encoder to an embedded android device (WaRP board) to use as an input.
The board uses a ARM cortex Freescale i.MX 6 SoloLite processor. A brief overview of what the board has to offer can be seen here.
In order to do so, I made this system service which runs in the background and reads from a rotary encoder connected over GPIO.
The input read from the rotary encoder (clockwise, counter clockwise and how much in either direction), is broadcast for other apps to read and use however they please.

Rotary encoder input using quadrature

The service is available on Github.
The documentation is available on Github as well but can also be found here.
The input is read from GPIO using a thread written in C which callsback to Java through the Java Native Interface (JNI).

Software block diagram:

The logic used to read the input can seen in the state transition diagram seen below in the state transition diagram and table used to model quadrature input.