Discover and connect a reader
Discovery finds the reader, gets USB permission, and hands you a ReaderInfo you turn into a session. See Device discovery for the model.
Start discovery and collect readers
val manager = sdk.startReaderDiscovery()
viewModelScope.launch {
manager.readers.collect { readers ->
_uiReaders.value = readers // render a picker
}
}
viewModelScope.launch {
manager.readerErrors.collect { e ->
_uiError.value = e.message // "why is there no reader?"
}
}readers only contains permissioned readers. An empty list with no readerErrors means nothing is plugged in.
Request permission
For SecuGen / BioMini, the manifest device_filter triggers the system dialog on attach. For EADAK / Aratek (and as a catch-all), call requestPermissions() when your activity receives the attach intent:
// MainActivity
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
if (intent.action == UsbManager.ACTION_USB_DEVICE_ATTACHED) {
manager.requestPermissions() // shows the dialog for readers lacking permission
}
}Observe manager.permissionGranted to enable the “connect” UI once permission is in place.
Open a session
val reader = manager.readers.value.firstOrNull() ?: return
val session = sdk.createFingerprintReaderSession(reader.id)createFingerprintReaderSession throws a CaptureError if discovery hasn’t started or no reader with that id is connected — guard on a non-empty readers list first.
[!TIP] The reference demo (
demo/) implements this exact pattern with an app-scoped holder that ownsSladeID+ReaderManager— copy it as a starting point.
Clean up
Call sdk.release() when you’re done to unregister the receiver and close reader handles.