Capturing Videos
To start recording, use thestartActivityForResult
method:
val intent = OzLivenessSDK.createStartIntent(listOf(OzAction.Smile, OzAction.Blank))
startActivityForResult(intent, REQUEST_CODE)
List<OzAction> actions = Arrays.asList(OzAction.Smile, OzAction.Scan);
Intent intent = OzLivenessSDK.createStartIntent(actions);
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 */ }
}
}
getSupportFragmentManager().beginTransaction()
.replace(R.id.content, LivenessFragment.Companion.create(actions, null, null, false))
.addToBackStack(null)
.commit();
// subscribing to the Fragment result
getSupportFragmentManager().setFragmentResultListener(OzLivenessSDK.Extra.REQUEST_CODE, this, (requestKey, result) -> {
switch (result.getInt(OzLivenessSDK.Extra.EXTRA_RESULT_CODE)) {
case OzLivenessResultCode.SUCCESS: {/* start analysis */}
default: {/* 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)
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @androidx.annotation.Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_CODE) {
List<OzAbstractMedia> sdkMediaResult = OzLivenessSDK.INSTANCE.getResultFromIntent(data);
String sdkErrorString = OzLivenessSDK.INSTANCE.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 you use our SDK just for capturing videos, omit the Checking Liveness and Face Biometry step.
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*
}
}