Added in API level 37
SerialManager
class SerialManager
| kotlin.Any | |
| ↳ | android.hardware.serial.SerialManager |
This class allows you to communicate with Serial ports.
Summary
| Public methods | |
|---|---|
| MutableList<SerialPort!> |
getPorts()Enumerates serial ports. |
| Unit |
registerSerialPortListener(executor: Executor, listener: SerialPortListener)Register a listener to monitor serial port connections and disconnections. |
| Unit |
unregisterSerialPortListener(listener: SerialPortListener)Unregister a listener that monitored serial port connections and disconnections. |
Public methods
getPorts
Added in API level 37
fun getPorts(): MutableList<SerialPort!>
Enumerates serial ports.
| Return | |
|---|---|
MutableList<SerialPort!> |
This value cannot be null. |
registerSerialPortListener
Added in API level 37
fun registerSerialPortListener(
executor: Executor,
listener: SerialPortListener
): Unit
Register a listener to monitor serial port connections and disconnections.
| Parameters | |
|---|---|
executor |
Executor: This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread. |
listener |
SerialPortListener: This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.IllegalStateException |
if this listener has already been registered. |
unregisterSerialPortListener
Added in API level 37
fun unregisterSerialPortListener(listener: SerialPortListener): Unit
Unregister a listener that monitored serial port connections and disconnections.
| Parameters | |
|---|---|
listener |
SerialPortListener: This value cannot be null. |