Core objects & lifecycle
Android Java SDK: Core objects & lifecycle
Core objects & lifecycle
Sdk owns configuration, devices and the runtime loop. sdk.glove().device(name, side) selects a configured glove. ReadChannel<T> reads a data type, Subscription owns a callback, and CaptureSession / CalibrationSession own explicit workflows.
Lifecycle order
- Select the device, obtain USB permission and prepare configuration.
- Construct the SDK on a worker thread; select the glove and required skeleton output.
- Call
sdk.start()and choose one runtime mode. - Use channels and sessions; post display work to the UI thread.
- When finished, close the SDK on a worker thread. To stop a background runner while keeping the SDK open, call
requestStop()andjoin()before restarting it.
connect() is a deprecated compatibility no-op. GloveDevice.close() closes that device, while Sdk.close() closes the whole instance. Do not reuse closed handles. Sessions also implement AutoCloseable; use try for explicit workflows.
App ownership
Give a clearly owned app component responsibility for the SDK session. Activity recreation must not create duplicate running instances in the process. Stop and release resources on a worker thread when the business session ends. Keep blocking waits off the main thread and do not depend on process termination for normal cleanup. The SDK releases its accepted host transport when destroyed; prepare a new transport for a new session.