Skip to content

Android SDK Reference ​

Every public class, property and method in the eKYC Android SDK. See Android SDK Integration for the integration guide.

CakeEkyc ​

class CakeEkyc — the SDK entry point.

FieldTypeDescription
upload(uploadImageRequest)Result<EkycResponse<UploadImageResponseData>>Uploads an image.
takeNID(activity, config, listener)UnitCaptures NID → uploads → checks sanity → checks tampering → extracts info. On failure the pipeline stops and listener.onError fires; otherwise listener.onSuccess receives a NIDCardResult.
checkNIDSanity(imageId, imageId2, cardType, specialTypeId)Result<EkycResponse<NIDSanityData>>Checks the sanity of NID images.
checkNIDTampering(imageId, imageId2, cardType, level)Result<EkycResponse<NIDTamperingData>>Checks for tampering in NID images.
readNIDInfo(imageId, imageId2, cardType)Result<EkycResponse<NIDCardData>>Extracts information from NID images.
takeFaces(activity, config, listener)UnitCaptures faces → uploads → checks sanity → checks liveness. Delivers a SelfieResult.
checkFaceSanity(imageId)Result<EkycResponse<FaceSanityData>>Checks the sanity of a face image.
checkLiveness(imageIds)Result<EkycResponse<FaceLivenessData>>Checks liveness of face images.
compareFaces(imageId1, imageId2)Result<EkycResponse<FaceComparedData>>Compares two face images.
close()UnitTerminates ongoing NID and face capturing tasks.
getInstance(context, config, executor)static Future<CakeEkyc>Creates a CakeEkyc instance asynchronously.
start(activity, pipeline)static UnitStarts the eKYC process with the provided pipeline.
start(fromPackage, fromActivity, hostActivityFullClassName, pipeline, args)static UnitStarts eKYC from a specific package and activity class.
start<T : EkycActivity>(activity, pipeline, hostActivityClass, args)static UnitStarts eKYC with a generic activity class.
start(from, intent, pipeline)static UnitStarts eKYC with a custom intent.
start(activity, fragmentContainerViewId, pipeline)static UnitStarts eKYC in a fragment container.

Results ​

NIDCardResult ​

data class NIDCardResult

FieldTypeDescription
cardTypeCardTypeThe type of NID card (CCCD).
frontSideImageEkycImage?The front side of the NID card.
backSideImageEkycImage?The back side of the NID card.
qrDataQRData?NID QR code data.
sanityResultEkycResponse<NIDSanityData>?Sanity check result.
tamperingResultEkycResponse<NIDTamperingData>?Tampering check result.
cardInfoEkycResponse<NIDCardData>?Extracted card details — name, ID number, dob, mrz.

NIDCardResult.QRData ​

FieldTypeDescription
rawString?String value resulting from the QR scan.
imageEkycImage?QR code image.

SelfieResult ​

data class SelfieResult

FieldTypeDescription
facesList<Face>?Captured faces.
sanityResultList<EkycResponse<FaceSanityData>>?Sanity check response per face image.
livenessResultEkycResponse<FaceLivenessData>?Liveness check result.

SelfieResult.Face ​

FieldTypeDescription
imageEkycImage?The portrait image.
gestureFaceGestureFace gesture: frontal, left, right, up, down.

Configuration ​

Config ​

data class Config

FieldTypeDescription
languageCodeStringvi for Vietnamese, en for English.
baseUrlStringBase URL for network requests.
networkConfigNetworkConfigNetwork configuration settings.
tokenProviderTokenProvider?Authentication token provider.
loggerLogger?Log sink.

Config.Builder ​

FieldTypeDescription
withLanguage(languageCode)BuilderSets languageCode.
withBaseUrl(baseUrl)BuilderSets baseUrl.
withToken(tokenProvider)BuilderSets tokenProvider.
withNetworkConfig(networkConfig)BuilderSets networkConfig.
withLogger(logger)BuilderSets logger.
build()ConfigCreates the Config.

NetworkConfig ​

FieldTypeDescription
readTimeoutMilliSecondsLongRead timeout, defaults to 0.
writeTimeoutMilliSecondsLongWrite timeout, defaults to 0.
connectTimeoutMilliSecondsLongConnection timeout, defaults to 0.
callTimeoutMilliSecondsLongTotal time allowed for the call, defaults to 60000.

TokenProvider ​

interface TokenProvider

FieldTypeDescription
getToken(timestamp, path, method)StringReturns an authentication token for the given request.
from(authToken)static TokenProviderCreates a provider from a static token.

Logger ​

FieldTypeDescription
info(log)UnitLogs an informational message.
error(log)UnitLogs an error message.
warning(log)UnitLogs a warning message.

TakeNIDConfig ​

FieldTypeDescription
cardTypeCardTypeCard type to capture, defaults to CardType.CCCD.
cardSidesList<CardSide>Sides to capture, defaults to [Front, Back].
requiredReviewBooleanRequire review of the captured image, defaults to true.
autoCaptureEnableBooleanAuto-capture once quality passes, defaults to true.
requiredScanQRBooleanRequire QR scanning, defaults to false.
captureOnlyBooleanCapture-only mode, defaults to false.
loadingViewView?Custom loading UI. Defaults to the SDK's own.
otherSideImagesMap<CardSide, EkycImage>The already-captured other side.

TakeFaceConfig ​

FieldTypeDescription
captureOnlyBooleanCapture-only mode, defaults to false.
loadingViewView?Custom loading UI.

Data Types ​

EkycImage ​

FieldTypeDescription
idString?Unique identifier after uploading to the server.
labelString?Label describing the image.
bitmapBitmap?The image data.

EkycResponse ​

FieldTypeDescription
dataT?The response data.
errorList<EkycErrorDetail>?Error details, if any.
codeInt?Response status code.
messageString?Response message.
signatureString?Response signature.
signatureTimestampString?Signature timestamp.
rawDataString?Raw data string.
requestString?The request.
responseBodyString?Raw response body.

EkycErrorDetail ​

FieldTypeDescription
codeString?Error code.
messageString?Error description.

CardType ​

FieldTypeDescription
idStringCard type identifier, e.g. vn.national_id.
nameStringCard type name, e.g. id_card.vn.national_id.
CCCDstatic CardTypeVietnamese National ID: id vn.national_id, name id_card.vn.national_id.

CardSide ​

sealed class CardSide — name must be front or back. Nested objects: Front, Back.

NIDSanityData ​

FieldTypeDescription
statusString?success or failure.
cardSanityCardSanity?Card sanity details.
image1NIDImage?First NID image used.
image2NIDImage?Second NID image used.
requestIdString?Request identifier.

CardSanity ​

FieldTypeDescription
verdictString?good when the check passed. See Verdict Definitions.
scoreDouble?Confidence score.
infoString?Additional information.

NIDTamperingData ​

FieldTypeDescription
statusString?Status of the tampering check.
cardTamperingCardTampering?Tampering check details.
requestIdString?Request identifier.
imageIdString?First image used.
imageId2String?Second image used.

CardTampering ​

FieldTypeDescription
verdictString?good when the check passed.
scoreDouble?Overall confidence score.
detailsList<TamperingDetail>?Individual tampering signals.

TamperingDetail ​

FieldTypeDescription
verdictString?The specific tampering verdict.
scoreDouble?Confidence score.
infoString?Additional information.

NIDCardData ​

FieldTypeDescription
statusString?Status of the extraction.
extractedDataOnImage1ExtractedData?Data from the first image.
extractedDataOnImage2ExtractedData?Data from the second image.
cardInfoList<CardInfo>?Consolidated card information.
requestIdString?Request identifier.

ExtractedData ​

FieldTypeDescription
idString?NID image identifier.
transformedImageIdString?Transformed image identifier.
cardBoxCardBox?Card bounding box.
qrQRData?QR code data.
ocrOCRData?OCR data.
mrzDataMRZData?MRZ data.

QRData / OCRData / MRZData ​

FieldTypeDescription
parsedFieldsList<ParsedField>?Parsed fields from this source.
rawString?Raw value. QRData only.
confidenceScoreDouble?Confidence in the extraction.

ParsedField ​

FieldTypeDescription
keyString?Field name.
valueString?Field value.
confidenceVerdictString?Confidence verdict.
confidenceScoreDouble?Confidence score.

CardInfo ​

FieldTypeDescription
keyString?Field name.
valueString?Field value.
confidenceVerdictString?Confidence verdict.
confidentScoreDouble?Confidence score.

CardBox / Point ​

FieldTypeDescription
topLeft topRight bottomLeft bottomRightPoint?Corners of the card box.
x yDouble?Point coordinates.

FaceSanityData ​

FieldTypeDescription
statusString?Status of the face sanity check.
portraitSanityPortraitSanity?Sanity details for the portrait.
requestIdString?Request identifier.
imagePortraitImageInfo?Portrait image information.
isSanityPassed()BooleanTrue when portraitSanity.verdict is good.

PortraitSanity ​

FieldTypeDescription
verdictString?Outcome of the sanity check.
scoreDouble?Confidence score.

FaceLivenessData ​

FieldTypeDescription
statusString?Status of the liveness check.
isLiveBoolean?Whether the face is live.
scoreDouble?Confidence score.
resultsList<LivenessResult>?Per-image liveness results.
requestIdString?Request identifier.
mainImageIdString?Main image used.

LivenessResult ​

FieldTypeDescription
idString?Image identifier.
isLiveBoolean?Whether this face is live.
scoreDouble?Confidence score.

FaceComparedData / ComparedResult ​

FieldTypeDescription
statusString?Status of the comparison.
comparedResultsList<ComparedResult>?Comparison results.
face1Id face2IdString?The compared face image ids.
scoreDouble?Similarity score.
resultString?matched or not matched.

Listeners and Events ​

NIDCapturingListener / FaceCapturingListener ​

FieldTypeDescription
onEvent(event)UnitAn event occurred during capture.
onError(error)UnitAn error occurred.
onSuccess(result)UnitCapture succeeded — NIDCardResult or SelfieResult.

EkycEvent ​

FieldTypeDescription
idIntEvent identifier.
paramsMap<String, Any>Event parameters.
timestampLongCreation time in milliseconds.
STEP_COMPLETE_EVENT-1A step completed.
STEP_RETRY_EVENT-2A step is being retried.
STEP_EXITED_EVENT-3A step was exited.
STEP_ENTERED_EVENT-4A step was entered.
TIME_OUT_EVENT-1000A timeout occurred.
FACE_SELFIE_ASSESSING_RESULT_EVENT-1001Result of a face selfie assessment.
FACE_LIVENESS_ASSESSING_RESULT_EVENT-1002Result of a face liveness assessment.
NID_ASSESSING_RESULT_EVENT-1003Result of an NID assessment.
LIVENESS_RESULT_EVENT-1004Result of a liveness check.
ON_BACK_NAV_PRESSED_EVENT-1005Device back navigation pressed.
ON_CREATE_ACTIVITY_EVENT-1006An activity was created.
ON_PERMISSION_NOT_GRANTED-1007Permission was not granted.
NID_CAPTURE_STARTED_EVENT-1008NID capture started.
NID_CAPTURE_ENDED_EVENT-1009NID capture ended.
NID_REVIEW_STARTED_EVENT-1010NID review started.
ON_ID_SHUTTLE_CLICKED_EVENT-1011Shutter button clicked.
ON_ID_AUTO_CAPTURE_SELECTED_EVENT-1012Auto-capture selected.
NID_REVIEW_ENDED_EVENT-1013NID review finished.
NID_REVIEW_ACCEPT_CLICKED_EVENT-1014Accept clicked during review.
NID_REVIEW_DENY_CLICKED_EVENT-1015Deny clicked during review.
FACE_CAPTURE_STARTED_EVENT-1016Face capture started.
FACE_CAPTURE_ENDED_EVENT-1017Face capture ended.
ON_BACK_BTN_CLICKED_EVENT-1018In-screen back button clicked.

EkycEvent.Builder ​

FieldTypeDescription
setEventId(id)BuilderSets the event id.
addParams(params)BuilderAdds multiple parameters.
addParam(key, value)BuilderAdds one parameter.
build()EkycEventCreates the event.

EkycConstant ​

Keys used inside EkycEvent.params.

FieldTypeDescription
STEP_NAME_KEYstep_nameStep name.
SELFIE_IMAGES_KEYselfie_imagesSelfie image data.
ASSESSING_CODE_KEYassessing_codeAssessment code.
ASSESSING_MESSAGE_KEYassessing_messageAssessment message.
OFFSET_KEYoffsetOffset data.
CARD_TYPE_KEYcard_typeCard type.
CARD_SIDE_KEYcard_sideCard side.
AUTO_CAPTURE_KEYauto_captureAuto-capture setting.
TIMESTAMP_KEYtimestampTimestamp.

EkycError ​

sealed class EkycError : RuntimeException()

FieldTypeDescription
TIMEOUT_CODE40000Timeout.
USER_CANCEL_CODE40001User cancellation.
PERMISSION_NOT_GRANTED_ERROR_CODE40002Permission denial.
CAMERA_ERROR_CODE40003Camera error.
UNEXPECTED_ERROR_CODE50000Unexpected error.
NID_SANITY_FAILED60000NID sanity failure.
NID_TAMPERING_FAILED60001NID tampering failure.
FACE_SANITY_FAILED60002Face sanity failure.
FACE_LIVENESS_FAILED60003Face liveness failure.

Nested: UserCanceledError, TimeoutError, PermissionNotGranted, CameraError, UnexpectedError, QualityFailed.

Next Steps ​

Developers