Usage
Kotlin Jetpack Compose
//Inside a composable function just do the following
@Composable
fun MyComposable() {
val context = LocalContext.current
camera.userLicense = stringResource(id = R.string.TouchlessLicenseKey)
val configuration =
TouchlessConfigurationBuilder.setUserLicense(stringResource(id = R.string.TouchlessLicenseKey))
.computeNfiqMetrics(true)
.useTouchlessLive(false)
camera.TouchlessCamera(context as Activity, configuration.setFingerScanDirection(1))
{ touchlessResults: TouchlessResults ->
}
}
Using Fragments in Kotlin or Java
In your activity_main.xml
file add the following:
<androidx.fragment.app.FragmentContainerView android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/main_container" />
Create a TouchlessFragment and call the YesidTouchlessCamera and pass in the license key
class YesidTouchlessFragment : Fragment() {
@RequiresApi(Build.VERSION_CODES.O)
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
val view = ComposeView(requireContext())
view.apply {
setContent {
Column(
modifier = Modifier.verticalScroll(rememberScrollState())
) {
MyComposable()
}
}
}
return view
}
@Composable
fun MyComposable() {
val context = LocalContext.current
camera.userLicense = stringResource(id = R.string.TouchlessLicenseKey)
val configuration =
TouchlessConfigurationBuilder.setUserLicense(stringResource(id = R.string.TouchlessLicenseKey))
.computeNfiqMetrics(true)
.useTouchlessLive(false)
camera.TouchlessCamera(context as Activity, configuration.setFingerScanDirection(1))
{ touchlessResults: TouchlessResults ->
}
}
}
On your activity then call the YesidTouchlessFragment()
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
supportFragmentManager.beginTransaction()
.replace(R.id.main_container, YesidTouchlessFragment()).commit()
}
}