Welcome to ARx API Docs
Binding the ARxAPI
4min
make sure your main activity implements the arxapi class mainactivity arxactivity() { add the following functions overrides override fun setonpreviewframelistener(camerainput bytearray) { } override fun onbuttonclick(button arxbutton) { } override fun onbuttonlongclick(button arxbutton) { } override fun ondeviceattach() { super ondeviceattach() } override fun ondevicedetach() { super ondevicedetach() } in order for the arxapi to be initialized, you must reference a uvccameratextureview in your layout this is the component you must add to your layout xml \<?xml version="1 0" encoding="utf 8"?> \<androidx constraintlayout widget constraintlayout xmlns\ android="http //schemas android com/apk/res/android" xmlns\ app="http //schemas android com/apk/res auto" xmlns\ tools="http //schemas android com/tools" android\ id="@+id/coordinatorlayout" android\ layout width="match parent" android\ layout height="match parent" tools\ context=" mainactivity"> \<com serenegiant usb widget uvccameratextureview android\ id="@+id/camera view" android\ layout width="wrap content" android\ layout height="400dp" android\ visibility="visible" app\ layout anchorgravity="center" app\ layout constraintbottom tobottomof="parent" app\ layout constraintend toendof="parent" app\ layout constraintstart tostartof="parent" app\ layout constrainttop totopof="parent" /> \</androidx constraintlayout widget constraintlayout> in order to initialize the api you must call the following function, passing the uvccameratextureview arxapi init(findviewbyid\<uvccameratextureview>(r id camera view)) uvccameratextureview is a widget that must be present in your main activity's layout here is an example of it integrated into the layout file in order to access the headset, you must make sure that the user has granted permissions here's an example of how to do so private val permissionarray = arrayof( manifest permission camera, manifest permission record audio ) private val activityresultlauncher = registerforactivityresult(activityresultcontracts requestmultiplepermissions()) { permissions > // handle permission granted/rejected if (permissions entries filter { it value == true } size == permissionarray size) { // initialize the arx api after the camera and record audio permission is given arxapi init(findviewbyid\<uvccameratextureview>(r id camera view)) } else { snackbar make( findviewbyid\<uvccameratextureview>(r id camera view), "please provide all the required permission", snackbar length long ) setaction("setting") { val intent = intent( settings action application details settings, uri fromparts("package", packagename, null) ) intent addflags(intent flag activity new task) startactivity(intent) } show() } } then in order to request permissions and start the headset, call activityresultlauncher launch(permissionarray)