Skip to content

Most visited

Recently visited




public abstract class I2cBusDriver
extends Object implements Closeable


I2C user driver. An I2cBusDriver defines an entire I2C bus with multiple possible devices attached to it. Individual I2cDevice objects can be opened and closed on the bus independently.


Public constructors


Public methods

void close()

Closes the bus.

abstract I2cDevice createI2cDevice(int address)

Creates an I2C device on the bus.

void open()

Opens the bus.

Inherited methods

From class java.lang.Object
From interface
From interface java.lang.AutoCloseable

Public constructors


I2cBusDriver ()

Public methods


void close ()

Closes the bus. This will be called just after the last device is closed by its owner. Any resources that need to be cleaned up can be done so here. This method may throw IOException to indicate I/O failure, but the bus will still be considered closed and may attempt to be re-opened in the future.

IOException on I/O failure; the bus will still be considered closed.


I2cDevice createI2cDevice (int address)

Creates an I2C device on the bus. This will be called when ownership of a single I2C device is requested. The driver should create and return a new I2cDevice object. The driver manager will internally make sure that no other I2C device is opened at this address until the returned device is closed.

address int: The I2C device address to open.
I2cDevice A new I2cDevice connected to the given address.
IOException on I/O failure; the I2C slave device will remain unowned.


void open ()

Opens the bus. This will be called just before the first device is requested on this bus. The driver may do any initialization needed to configure the bus for use here.

IOException on I/O failure; the bus will remain closed.
This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields


Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience. (Dec 2017 Android Platform & Tools Survey)