Bio Login with Backend V2
The Bio Login module supports multiple selfie capture methods for biometric authentication.
In all methods, the result must be uploaded to the backend for verification.
Basic Flow
The typical usage of the Bio Login module follows these steps:
-
Initialize the desired selfie capture type
- Choose between Manual Selfie Capture, Automatic Selfie Capture, or Pose Estimation based on your integration needs.
- Attach an observer to receive the captured selfie data (Bitmap).
-
Capture the selfie
- The module either automatically captures the image when the user is in the correct position or waits for the user to press a button.
- In the case of Pose Estimation, the module ensures the face/head pose meets the criteria before capturing.
-
Upload the captured selfie
- Call the upload method on the Bio Login module with the captured Bitmap.
- Provide a callback to handle the result of the upload (success/failure).
-
Handle post-upload actions
- Display success or error messages to the user.
- Remove the fragment from the UI if needed to maintain a clean navigation flow.
This basic flow ensures that the captured selfie is validated, uploaded, and monitored correctly across all capture methods.
Manual Selfie Capture
The user manually triggers selfie capture (e.g., by pressing a button).
Add the imports below:
import ai.amani.sdk.Amani
import ai.amani.sdk.interfaces.ManualSelfieCaptureObserver
import android.graphics.Bitmap
Then capture a selfie manually as shown below:
val fragment = Amani.sharedInstance().BioLogin()
.ManualSelfieCapture()
.documentType("XXX_SE_0") // Bio login selfie document type (default: "XXX_SE_0")
.userInterfaceTexts(
selfieDescriptionText = "Position your face inside the oval and take a photo"
)
.userInterfaceColors(
appFontColor = R.color.color_black, // Description / on-screen text color
appBackgroundColor = R.color.white, // Screen background color
ovalViewColor = R.color.any_color, // Oval frame color
manualButtonColor = R.color.any_color2 // Capture button color
)
.observer(object : ManualSelfieCaptureObserver {
override fun cb(bitmap: Bitmap?) {
bitmap?.let {
//Call the upload function
}
}
})
.build()
fragment?.let {
navigateToFragmentMethod(it)
}
Configuration Options — Manual Selfie
All configuration methods are optional and can be chained before build(). Any parameter left out keeps its default value.
| Method | Parameter | Type | Description |
|---|---|---|---|
documentType | docType | String | Bio login selfie document type. Default: "XXX_SE_0". |
userInterfaceTexts | selfieDescriptionText | String? | Instruction text shown on the selfie screen. |
userInterfaceColors | appFontColor | @ColorRes Int? | On-screen text color. |
appBackgroundColor | @ColorRes Int? | Screen background color. | |
ovalViewColor | @ColorRes Int? | Oval frame color. | |
manualButtonColor | @ColorRes Int? | Capture button color. |
Auto Selfie Capture
Automatically captures the selfie when the user is in the correct position and lighting.
Add the imports below:
import ai.amani.sdk.Amani
import ai.amani.sdk.interfaces.AutoSelfieCaptureObserver
import android.graphics.Bitmap
Then capture a selfie automatically as shown below:
val fragment = Amani.sharedInstance().BioLogin()
.AutoSelfieCapture()
.documentType("XXX_SE_0") // Bio login selfie document type (default: "XXX_SE_0")
.timeOutManualButton(20) // Seconds before the manual capture button appears
.userInterfaceTexts(
faceNotFoundText = "Face not found",
holdStableText = "Hold stable, while taking photo",
faceIsTooFarText = "Be sure to be close enough"
)
.userInterfaceColors(
appFontColor = R.color.color_black, // On-screen message text color
manualButtonColor = R.color.any_color, // Manual capture button color
ovalViewStartColor = R.color.any_color2, // Oval frame + counter color (start state)
ovalViewSuccessColor = R.color.approve_green // Oval color on successful capture
)
.observer(object : AutoSelfieCaptureObserver {
override fun cb(bitmap: Bitmap?) {
bitmap?.let {
//Call the upload function
}
}
})
.build()
fragment?.let {
navigateToFragmentMethod(it)
}
Configuration Options — Auto Selfie
All configuration methods are optional and can be chained before build(). Any parameter left out keeps its default value.
| Method | Parameter | Type | Description |
|---|---|---|---|
documentType | docType | String | Bio login selfie document type. Default: "XXX_SE_0". |
timeOutManualButton | timeOut | Int | Seconds to wait before the manual capture button is shown. |
userInterfaceTexts | faceNotFoundText | String? | Shown when no face is detected. |
holdStableText | String? | Shown while the photo is being taken. | |
faceIsTooFarText | String? | Shown when the face is too far from the camera. | |
userInterfaceColors | appFontColor | @ColorRes Int? | On-screen message text color. |
manualButtonColor | @ColorRes Int? | Manual capture button color. | |
ovalViewStartColor | @ColorRes Int? | Oval frame and counter animation color (start state). | |
ovalViewSuccessColor | @ColorRes Int? | Oval color on successful capture. |
Pose Estimation Capture
Captures selfie after verifying head/face pose.
Add the imports below:
import ai.amani.sdk.Amani
import ai.amani.sdk.modules.selfie.pose_estimation.observable.OnFailurePoseEstimation
import ai.amani.sdk.modules.selfie.pose_estimation.observable.PoseEstimationObserver
import android.graphics.Bitmap
Then capture a selfie via pose estimation as shown below:
val fragment = Amani.sharedInstance().BioLogin()
.PoseEstimation()
.documentType("XXX_SE_0") // Bio login selfie document type (default: "XXX_SE_0")
.requestedPoseNumber(1) // Number of random poses (must be non-null and greater than 0)
.ovalViewAnimationDurationMilSec(500) // Oval view animation duration, in milliseconds
.userInterfaceTexts(
faceNotInside = "Your face is not inside the area",
faceNotStraight = "Your face is not straight",
faceIsTooFar = "Your face is too far from camera",
holdPhoneVertically = "Please keep the phone straight",
alertTitle = "Verification Failed",
alertDescription = "Failed",
alertTryAgain = "Try Again",
turnLeft = "Turn your head left",
turnRight = "Turn your head right",
turnUp = "Turn your head up",
turnDown = "Turn your head down",
faceStraight = "Look straight at the camera"
)
.userInterfaceColors(
ovalViewStartColor = R.color.white, // Oval frame color (start state)
ovalViewSuccessColor = R.color.approve_green, // Oval color on success
ovalViewErrorColor = R.color.error_red, // Oval color on error
alertTitleFontColor = R.color.color_white, // Failure alert title text color
alertDescriptionFontColor = R.color.white, // Failure alert description text color
alertTryAgainFontColor = R.color.white, // "Try again" text color
alertBackgroundFontColor = R.color.color_pink, // Failure alert background color
appFontColor = R.color.white // On-screen guidance text color
)
.userInterfaceDrawables(
mainGuideLeft = R.drawable.ic_guide_left, // Main guide arrow: turn left
mainGuideRight = R.drawable.ic_guide_right, // Main guide arrow: turn right
mainGuideUp = R.drawable.ic_guide_up, // Main guide arrow: turn up
mainGuideDown = R.drawable.ic_guide_down, // Main guide arrow: turn down
mainGuideStraight = R.drawable.ic_guide_straight, // Main guide: look straight
secondaryGuideLeft = R.drawable.ic_hint_left, // Secondary hint: turn left
secondaryGuideRight = R.drawable.ic_hint_right, // Secondary hint: turn right
secondaryGuideUp = R.drawable.ic_hint_up, // Secondary hint: turn up
secondaryGuideDown = R.drawable.ic_hint_down // Secondary hint: turn down
)
.userInterfaceVisibilities(
mainGuideVisibility = true, // Show/hide the main guide (default: true)
secondaryGuideVisibility = true // Show/hide the secondary guide (default: true)
)
.observer(object : PoseEstimationObserver {
override fun onSuccess(bitmap: Bitmap?) {
bitmap?.let {
//Call the upload function
}
}
override fun onFailure(reason: OnFailurePoseEstimation, currentAttempt: Int) {
// Handle failure case
}
override fun onError(error: Error) {
// Handle error
}
})
.build()
fragment?.let {
navigateToFragmentMethod(it)
}
Configuration Options — Pose Estimation
All configuration methods below are optional and can be chained before build(). Any parameter left out keeps its default value.
userInterfaceColors is applied all-or-nothing: every one of its eight color parameters must be provided (non-null). If any color is omitted, none of the custom colors are applied and the defaults are kept.
| Method | Parameter | Type | Description |
|---|---|---|---|
documentType | docType | String | Bio login selfie document type. Default: "XXX_SE_0". |
requestedPoseNumber | requestedPoseNumber | Int | Number of random poses requested. Must be non-null and greater than 0. |
ovalViewAnimationDurationMilSec | ovalViewAnimationDurationMilSec | Int | Oval view animation duration in milliseconds. |
userInterfaceTexts | faceNotInside | String? | Shown when the face is outside the oval area. |
faceNotStraight | String? | Shown when the face is not straight. | |
faceIsTooFar | String? | Shown when the face is too far from the camera. | |
holdPhoneVertically | String? | Shown when the phone is not held vertically. | |
alertTitle | String? | Title of the failure alert dialog. | |
alertDescription | String? | Description of the failure alert dialog. | |
alertTryAgain | String? | "Try again" button text of the failure alert. | |
turnLeft / turnRight / turnUp / turnDown | String? | Head-turn guidance texts for each direction. | |
faceStraight | String? | Guidance text to look straight at the camera. | |
userInterfaceColors | ovalViewStartColor | @ColorRes Int? | Oval frame color in the start state. |
ovalViewSuccessColor | @ColorRes Int? | Oval color on successful pose. | |
ovalViewErrorColor | @ColorRes Int? | Oval color on error. | |
alertTitleFontColor | @ColorRes Int? | Failure alert title text color. | |
alertDescriptionFontColor | @ColorRes Int? | Failure alert description text color. | |
alertTryAgainFontColor | @ColorRes Int? | "Try again" text color. | |
alertBackgroundFontColor | @ColorRes Int? | Failure alert background color. | |
appFontColor | @ColorRes Int? | On-screen guidance text color. | |
userInterfaceDrawables | mainGuideLeft/Right/Up/Down | @DrawableRes Int? | Main guide arrows for each head-turn direction. |
mainGuideStraight | @DrawableRes Int? | Main guide for looking straight. | |
secondaryGuideLeft/Right/Up/Down | @DrawableRes Int? | Secondary hint guides for each direction. | |
userInterfaceVisibilities | mainGuideVisibility | Boolean | Show/hide the main guide. Default: true. |
secondaryGuideVisibility | Boolean | Show/hide the secondary guide. Default: true. |
Upload
Uploads the captured selfie data to the backend for verification.
- Use the
uploadmethod provided by the Bio Login module. - Provide the current activity/context and a callback to handle the result.
- The callback receives a Boolean indicating success or failure of the BioLogin status.
Example
Add the imports below:
import ai.amani.sdk.Amani
import ai.amani.sdk.interfaces.BioLoginUploadCallBack
Then upload the captured selfie as shown below:
Amani.sharedInstance().BioLogin().upload(requireContext(),
object : BioLoginUploadCallBack {
override fun cb(result: Boolean?) {
// Handle upload result
}
}
)