June 2017
Intermediate to advanced
232 pages
5h 4m
English
Once we have defined the event, we have to create a callback class that will handle the event when it will be raised. A callback class must extend GpioCallback. So in our project, the callback class will be:
private class SensorCallBack extends GpioCallback { @Override public boolean onGpioEdge(Gpio gpio) { try { boolean callBackState = gpio.getValue(); Log.d(TAG, "Callback state ["+callBackState+"]"); } catch(IOException ioe) { ioe.printStackTrace(); } return true; } @Override public void onGpioError(Gpio gpio, int error) { super.onGpioError(gpio, error); }}
At the end of MainActivity.java, just before the last right brace, add the class shown previously.
There are two important methods that we have to override ...
Read now
Unlock full access