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.
| Field | Type | Description |
|---|---|---|
upload(uploadImageRequest) | Result<EkycResponse<UploadImageResponseData>> | Uploads an image. |
takeNID(activity, config, listener) | Unit | Captures 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) | Unit | Captures 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() | Unit | Terminates ongoing NID and face capturing tasks. |
getInstance(context, config, executor) | static Future<CakeEkyc> | Creates a CakeEkyc instance asynchronously. |
start(activity, pipeline) | static Unit | Starts the eKYC process with the provided pipeline. |
start(fromPackage, fromActivity, hostActivityFullClassName, pipeline, args) | static Unit | Starts eKYC from a specific package and activity class. |
start<T : EkycActivity>(activity, pipeline, hostActivityClass, args) | static Unit | Starts eKYC with a generic activity class. |
start(from, intent, pipeline) | static Unit | Starts eKYC with a custom intent. |
start(activity, fragmentContainerViewId, pipeline) | static Unit | Starts eKYC in a fragment container. |
Results
NIDCardResult
data class NIDCardResult
| Field | Type | Description |
|---|---|---|
cardType | CardType | The type of NID card (CCCD). |
frontSideImage | EkycImage? | The front side of the NID card. |
backSideImage | EkycImage? | The back side of the NID card. |
qrData | QRData? | NID QR code data. |
sanityResult | EkycResponse<NIDSanityData>? | Sanity check result. |
tamperingResult | EkycResponse<NIDTamperingData>? | Tampering check result. |
cardInfo | EkycResponse<NIDCardData>? | Extracted card details — name, ID number, dob, mrz. |
NIDCardResult.QRData
| Field | Type | Description |
|---|---|---|
raw | String? | String value resulting from the QR scan. |
image | EkycImage? | QR code image. |
SelfieResult
data class SelfieResult
| Field | Type | Description |
|---|---|---|
faces | List<Face>? | Captured faces. |
sanityResult | List<EkycResponse<FaceSanityData>>? | Sanity check response per face image. |
livenessResult | EkycResponse<FaceLivenessData>? | Liveness check result. |
SelfieResult.Face
| Field | Type | Description |
|---|---|---|
image | EkycImage? | The portrait image. |
gesture | FaceGesture | Face gesture: frontal, left, right, up, down. |
Configuration
Config
data class Config
| Field | Type | Description |
|---|---|---|
languageCode | String | vi for Vietnamese, en for English. |
baseUrl | String | Base URL for network requests. |
networkConfig | NetworkConfig | Network configuration settings. |
tokenProvider | TokenProvider? | Authentication token provider. |
logger | Logger? | Log sink. |
Config.Builder
| Field | Type | Description |
|---|---|---|
withLanguage(languageCode) | Builder | Sets languageCode. |
withBaseUrl(baseUrl) | Builder | Sets baseUrl. |
withToken(tokenProvider) | Builder | Sets tokenProvider. |
withNetworkConfig(networkConfig) | Builder | Sets networkConfig. |
withLogger(logger) | Builder | Sets logger. |
build() | Config | Creates the Config. |
NetworkConfig
| Field | Type | Description |
|---|---|---|
readTimeoutMilliSeconds | Long | Read timeout, defaults to 0. |
writeTimeoutMilliSeconds | Long | Write timeout, defaults to 0. |
connectTimeoutMilliSeconds | Long | Connection timeout, defaults to 0. |
callTimeoutMilliSeconds | Long | Total time allowed for the call, defaults to 60000. |
TokenProvider
interface TokenProvider
| Field | Type | Description |
|---|---|---|
getToken(timestamp, path, method) | String | Returns an authentication token for the given request. |
from(authToken) | static TokenProvider | Creates a provider from a static token. |
Logger
| Field | Type | Description |
|---|---|---|
info(log) | Unit | Logs an informational message. |
error(log) | Unit | Logs an error message. |
warning(log) | Unit | Logs a warning message. |
TakeNIDConfig
| Field | Type | Description |
|---|---|---|
cardType | CardType | Card type to capture, defaults to CardType.CCCD. |
cardSides | List<CardSide> | Sides to capture, defaults to [Front, Back]. |
requiredReview | Boolean | Require review of the captured image, defaults to true. |
autoCaptureEnable | Boolean | Auto-capture once quality passes, defaults to true. |
requiredScanQR | Boolean | Require QR scanning, defaults to false. |
captureOnly | Boolean | Capture-only mode, defaults to false. |
loadingView | View? | Custom loading UI. Defaults to the SDK's own. |
otherSideImages | Map<CardSide, EkycImage> | The already-captured other side. |
TakeFaceConfig
| Field | Type | Description |
|---|---|---|
captureOnly | Boolean | Capture-only mode, defaults to false. |
loadingView | View? | Custom loading UI. |
Data Types
EkycImage
| Field | Type | Description |
|---|---|---|
id | String? | Unique identifier after uploading to the server. |
label | String? | Label describing the image. |
bitmap | Bitmap? | The image data. |
EkycResponse
| Field | Type | Description |
|---|---|---|
data | T? | The response data. |
error | List<EkycErrorDetail>? | Error details, if any. |
code | Int? | Response status code. |
message | String? | Response message. |
signature | String? | Response signature. |
signatureTimestamp | String? | Signature timestamp. |
rawData | String? | Raw data string. |
request | String? | The request. |
responseBody | String? | Raw response body. |
EkycErrorDetail
| Field | Type | Description |
|---|---|---|
code | String? | Error code. |
message | String? | Error description. |
CardType
| Field | Type | Description |
|---|---|---|
id | String | Card type identifier, e.g. vn.national_id. |
name | String | Card type name, e.g. id_card.vn.national_id. |
CCCD | static CardType | Vietnamese 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
| Field | Type | Description |
|---|---|---|
status | String? | success or failure. |
cardSanity | CardSanity? | Card sanity details. |
image1 | NIDImage? | First NID image used. |
image2 | NIDImage? | Second NID image used. |
requestId | String? | Request identifier. |
CardSanity
| Field | Type | Description |
|---|---|---|
verdict | String? | good when the check passed. See Verdict Definitions. |
score | Double? | Confidence score. |
info | String? | Additional information. |
NIDTamperingData
| Field | Type | Description |
|---|---|---|
status | String? | Status of the tampering check. |
cardTampering | CardTampering? | Tampering check details. |
requestId | String? | Request identifier. |
imageId | String? | First image used. |
imageId2 | String? | Second image used. |
CardTampering
| Field | Type | Description |
|---|---|---|
verdict | String? | good when the check passed. |
score | Double? | Overall confidence score. |
details | List<TamperingDetail>? | Individual tampering signals. |
TamperingDetail
| Field | Type | Description |
|---|---|---|
verdict | String? | The specific tampering verdict. |
score | Double? | Confidence score. |
info | String? | Additional information. |
NIDCardData
| Field | Type | Description |
|---|---|---|
status | String? | Status of the extraction. |
extractedDataOnImage1 | ExtractedData? | Data from the first image. |
extractedDataOnImage2 | ExtractedData? | Data from the second image. |
cardInfo | List<CardInfo>? | Consolidated card information. |
requestId | String? | Request identifier. |
ExtractedData
| Field | Type | Description |
|---|---|---|
id | String? | NID image identifier. |
transformedImageId | String? | Transformed image identifier. |
cardBox | CardBox? | Card bounding box. |
qr | QRData? | QR code data. |
ocr | OCRData? | OCR data. |
mrzData | MRZData? | MRZ data. |
QRData / OCRData / MRZData
| Field | Type | Description |
|---|---|---|
parsedFields | List<ParsedField>? | Parsed fields from this source. |
raw | String? | Raw value. QRData only. |
confidenceScore | Double? | Confidence in the extraction. |
ParsedField
| Field | Type | Description |
|---|---|---|
key | String? | Field name. |
value | String? | Field value. |
confidenceVerdict | String? | Confidence verdict. |
confidenceScore | Double? | Confidence score. |
CardInfo
| Field | Type | Description |
|---|---|---|
key | String? | Field name. |
value | String? | Field value. |
confidenceVerdict | String? | Confidence verdict. |
confidentScore | Double? | Confidence score. |
CardBox / Point
| Field | Type | Description |
|---|---|---|
topLeft topRight bottomLeft bottomRight | Point? | Corners of the card box. |
x y | Double? | Point coordinates. |
FaceSanityData
| Field | Type | Description |
|---|---|---|
status | String? | Status of the face sanity check. |
portraitSanity | PortraitSanity? | Sanity details for the portrait. |
requestId | String? | Request identifier. |
image | PortraitImageInfo? | Portrait image information. |
isSanityPassed() | Boolean | True when portraitSanity.verdict is good. |
PortraitSanity
| Field | Type | Description |
|---|---|---|
verdict | String? | Outcome of the sanity check. |
score | Double? | Confidence score. |
FaceLivenessData
| Field | Type | Description |
|---|---|---|
status | String? | Status of the liveness check. |
isLive | Boolean? | Whether the face is live. |
score | Double? | Confidence score. |
results | List<LivenessResult>? | Per-image liveness results. |
requestId | String? | Request identifier. |
mainImageId | String? | Main image used. |
LivenessResult
| Field | Type | Description |
|---|---|---|
id | String? | Image identifier. |
isLive | Boolean? | Whether this face is live. |
score | Double? | Confidence score. |
FaceComparedData / ComparedResult
| Field | Type | Description |
|---|---|---|
status | String? | Status of the comparison. |
comparedResults | List<ComparedResult>? | Comparison results. |
face1Id face2Id | String? | The compared face image ids. |
score | Double? | Similarity score. |
result | String? | matched or not matched. |
Listeners and Events
NIDCapturingListener / FaceCapturingListener
| Field | Type | Description |
|---|---|---|
onEvent(event) | Unit | An event occurred during capture. |
onError(error) | Unit | An error occurred. |
onSuccess(result) | Unit | Capture succeeded — NIDCardResult or SelfieResult. |
EkycEvent
| Field | Type | Description |
|---|---|---|
id | Int | Event identifier. |
params | Map<String, Any> | Event parameters. |
timestamp | Long | Creation time in milliseconds. |
STEP_COMPLETE_EVENT | -1 | A step completed. |
STEP_RETRY_EVENT | -2 | A step is being retried. |
STEP_EXITED_EVENT | -3 | A step was exited. |
STEP_ENTERED_EVENT | -4 | A step was entered. |
TIME_OUT_EVENT | -1000 | A timeout occurred. |
FACE_SELFIE_ASSESSING_RESULT_EVENT | -1001 | Result of a face selfie assessment. |
FACE_LIVENESS_ASSESSING_RESULT_EVENT | -1002 | Result of a face liveness assessment. |
NID_ASSESSING_RESULT_EVENT | -1003 | Result of an NID assessment. |
LIVENESS_RESULT_EVENT | -1004 | Result of a liveness check. |
ON_BACK_NAV_PRESSED_EVENT | -1005 | Device back navigation pressed. |
ON_CREATE_ACTIVITY_EVENT | -1006 | An activity was created. |
ON_PERMISSION_NOT_GRANTED | -1007 | Permission was not granted. |
NID_CAPTURE_STARTED_EVENT | -1008 | NID capture started. |
NID_CAPTURE_ENDED_EVENT | -1009 | NID capture ended. |
NID_REVIEW_STARTED_EVENT | -1010 | NID review started. |
ON_ID_SHUTTLE_CLICKED_EVENT | -1011 | Shutter button clicked. |
ON_ID_AUTO_CAPTURE_SELECTED_EVENT | -1012 | Auto-capture selected. |
NID_REVIEW_ENDED_EVENT | -1013 | NID review finished. |
NID_REVIEW_ACCEPT_CLICKED_EVENT | -1014 | Accept clicked during review. |
NID_REVIEW_DENY_CLICKED_EVENT | -1015 | Deny clicked during review. |
FACE_CAPTURE_STARTED_EVENT | -1016 | Face capture started. |
FACE_CAPTURE_ENDED_EVENT | -1017 | Face capture ended. |
ON_BACK_BTN_CLICKED_EVENT | -1018 | In-screen back button clicked. |
EkycEvent.Builder
| Field | Type | Description |
|---|---|---|
setEventId(id) | Builder | Sets the event id. |
addParams(params) | Builder | Adds multiple parameters. |
addParam(key, value) | Builder | Adds one parameter. |
build() | EkycEvent | Creates the event. |
EkycConstant
Keys used inside EkycEvent.params.
| Field | Type | Description |
|---|---|---|
STEP_NAME_KEY | step_name | Step name. |
SELFIE_IMAGES_KEY | selfie_images | Selfie image data. |
ASSESSING_CODE_KEY | assessing_code | Assessment code. |
ASSESSING_MESSAGE_KEY | assessing_message | Assessment message. |
OFFSET_KEY | offset | Offset data. |
CARD_TYPE_KEY | card_type | Card type. |
CARD_SIDE_KEY | card_side | Card side. |
AUTO_CAPTURE_KEY | auto_capture | Auto-capture setting. |
TIMESTAMP_KEY | timestamp | Timestamp. |
EkycError
sealed class EkycError : RuntimeException()
| Field | Type | Description |
|---|---|---|
TIMEOUT_CODE | 40000 | Timeout. |
USER_CANCEL_CODE | 40001 | User cancellation. |
PERMISSION_NOT_GRANTED_ERROR_CODE | 40002 | Permission denial. |
CAMERA_ERROR_CODE | 40003 | Camera error. |
UNEXPECTED_ERROR_CODE | 50000 | Unexpected error. |
NID_SANITY_FAILED | 60000 | NID sanity failure. |
NID_TAMPERING_FAILED | 60001 | NID tampering failure. |
FACE_SANITY_FAILED | 60002 | Face sanity failure. |
FACE_LIVENESS_FAILED | 60003 | Face liveness failure. |
Nested: UserCanceledError, TimeoutError, PermissionNotGranted, CameraError, UnexpectedError, QualityFailed.
Next Steps
- Android SDK Integration — the integration guide
- Mobile SDK Overview — concepts shared across platforms