Android: get started¶
Requirements¶
| Min SDK | 28 (Android 9) |
| Native ABIs | arm64-v8a, armeabi-v7a, x86_64 |
| Hardware | USB host (USB-C OTG); Bluetooth LE only for wireless status |
| Language | Kotlin (coroutines and Flow throughout; Java interop works) |
Install¶
Download trinet-sdk-0.5.3.aar from the SDK repository
and add it as a flat-dir dependency. A flat AAR carries no POM, so declare its runtime dependencies
yourself.
settings.gradle.kts
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
flatDir { dirs("aar") }
}
}
app/build.gradle.kts
android {
defaultConfig { minSdk = 28 }
buildFeatures { compose = true }
}
dependencies {
implementation(":trinet-sdk-0.5.3@aar")
implementation("androidx.core:core-ktx:1.13.1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.9.0")
// Only if you use the SDK's Compose UI widgets:
implementation(platform("androidx.compose:compose-bom:2024.10.00"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.material3:material3")
}
Manifest¶
Three things are needed for any app that talks to a Trinet camera:
- the USB host feature;
- the CAMERA permission — Android silently denies USB access to video devices without it, so request it at runtime too;
- a
USB_DEVICE_ATTACHEDfilter (recommended) — your activity then opens automatically when a camera is plugged in, and Android pre-grants USB access to it.
AndroidManifest.xml
<uses-feature android:name="android.hardware.usb.host" android:required="true" />
<uses-permission android:name="android.permission.CAMERA" />
<activity android:name=".MainActivity" android:exported="true" android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
</intent-filter>
<meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="@xml/device_filter" />
</activity>
res/xml/device_filter.xml (decimal IDs)
<resources>
<usb-device vendor-id="8711" product-id="22" />
<usb-device vendor-id="8711" product-id="24" />
<usb-device vendor-id="8711" product-id="26" />
</resources>
The same IDs are available in code as DeviceInfo.TRINET_VID and DeviceInfo.TRINET_PIDS. The USB
product ID does not tell you which camera model is attached — see
stereo cameras.
Open a camera¶
// All attached Trinet cameras
val attached = DeviceDiscovery.connectedDevices(context)
// Ask for USB permission (suspends until the user answers; true if already granted)
val granted = DeviceDiscovery.requestPermission(context, attached.first())
// Or all in one: discover, ask, open — off the main thread
val device: TrinetDevice? = withContext(Dispatchers.IO) {
DeviceDiscovery.openFirstAvailable(context)
}
If the user denies permission or another app holds the camera, unplugging and reconnecting is the reliable reset — prompt the user to do that.
Next: Stream and preview. Full details, including lifecycle and reconnecting after the camera re-enumerates: getting-started guide on GitHub.