Digi adds to Android an API to manage these GPIO interfaces.
You can configure them, read and set values, and listen for state changes.
In the Digi APIx javadoc you can find a complete list of the available methods in this API.

Detect GPIO interruptions

When a GPIO is configured as INTERRUPT_EDGE_RISING, INTERRUPT_EDGE_FALLING or INTERRUPT_EDGE_BOTH, you can register a listener and be notified when its value changes.
To do so, you have to subscribe a IGPIOListener to the GPIO object by using the registerListener(IGPIOListener) method.

The registered listener class, MyGPIOListener, must implement the IGPIOListener interface.
This interface defines the valueChanged(GPIOValue) method, which is called whenever the value of the GPIO changes.

Note that it is possible to have more than one IGPIOListener waiting for updates in the same GPIO.
If you no longer wish to receive GPIO value updates in a determined listener, use the unregisterListener(IGPIOListener) method to unsubscribe an already registered listener.

You can also configure the polling rate, that is, the amount of milliseconds between checks for changes in the GPIO value.
By default, it is configured to 100 milliseconds, but you can change it by using the setPollingRate(int) method or read it with the getPollingRate() method.

GPIO example

Example: GPIO

The GPIO Sample Application demonstrates the usage of the GPIO API. In this example, one GPIO is configured as input and another as output. You can press the virtual button to switch on and off the User 0 LED corresponding to the output GPIO.