edited September 2018 in User projects

is there a Java API for using RPI3 GPIO ?



    `# GPIO

    Accessing GPIO is possible just the same way you would do it in Linux (via sysfs). We are also planning on adding proper Java API for that, but it will take a while.`

    Hope we could use such API near in the future. Waiting for it!

  • How is the GPIO access possible from within an Android (Java) app? How do we need to set permissions to access sysfs?

    The Java method

    public boolean activationPin(){
    String command = String.format("echo %d > /sys/class/gpio/export",;
    try {
    Runtime.getRuntime().exec(new String[] {"su", "-c", command});
    return true;
    } catch (IOException e) {
    return false;

    leads to the exception " Cannot run program "su": error=13, Permission denied"

  • After calling "su" you will see a permission dialog. You need to confirm it once.

Sign In or Register to comment.