Starting with Preview 7, the Android Things API services are not built as new instances. Instead, they gain access in the form of singles through getInstance()
more in accordance with the Android API paradigms. Some of the classes, for example, have
PeripheralManagerServicealso been renamed.
Be sure to update the application to use the Preview 7 SDK:
dependencies {
compileOnly 'com.google.android.things:androidthings:0.7-devpreview'
}
, PeripheralManager:
PeripheralManager manager = PeripheralManager.getInstance();
Gpio ledGpio;
try {
ledGpio = manager.openGpio("BCM6");
ledGpio.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
} catch (IOException e) {
Log.e(TAG, "Error configuring GPIO pins", e);
}
Android Things API
, - API-, .