Capturing Videos
To start recording, use thestartActivityForResult
method:
val intent = OzLivenessSDK.createStartIntent(listOf(OzAction.Smile, OzAction.Blank))
startActivityForResult(intent, REQUEST_CODE)
actions
– a list of user actions while recording video.
For Fragment, use the code below. LivenessFragment
is the Fragment representation of the Liveness screen UI.
childFragmentManager.beginTransaction()
.replace(R.id.content, LivenessFragment.create(actions))
.commit()
// subscribing to the Fragment result
childFragmentManager.setFragmentResultListener(OzLivenessSDK.Extra.REQUEST_CODE, this) { _, result ->
when (result.getInt(OzLivenessSDK.Extra.EXTRA_RESULT_CODE)) {
OzLivenessResultCode.SUCCESS -> { /* start analysis */ }
else -> { /* show error */ }
}
}
To obtain the captured video, use theonActivityResult
method:
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == REQUEST_CODE) {
sdkMediaResult = OzLivenessSDK.getResultFromIntent(data)
sdkErrorString = OzLivenessSDK.getErrorFromIntent(data)
}
}
sdkMediaResult
– an object with video capturing results for interactions with Oz API (a list of the OzAbstractMedia objects),sdkErrorString
– description of errors, if any.
If a user closes the capturing screen manually, resultCode
receives the Activity.RESULT_CANCELED
value.
Code example:
when (resultCode) {
Activity.RESULT_CANCELED -> *USER CLOSED THE SCREEN*
OzLivenessResultCode.SUCCESS -> {
val sdkMediaResult = OzLivenessSDK.getResultFromIntent(data)
*SUCCESS*
}
else -> {
val errorMessage = OzLivenessSDK.getErrorFromIntent(data)
*FAILURE*
}
}
Last updated
Was this helpful?