In this section, you will find all the necessary information for using and integrating the Unico IDCloud SDK into your Android applications for document capture
This guide has been designed to help you implement the Android SDK quickly and easily. Below, you will find a step-by-step process for the entire integration. After that, if you wish to customize the experience, be sure to check the Android Customization section.
In this camera mode, there is a capture frame to assist the user in positioning the document correctly. Once the document is properly positioned, the user must click the button to take a photo of the document.
The SDK does not perform any validation of what is being captured.
In this camera mode, it is possible to capture the following documents:
CPF: Capture the front of the CPF;
CNH: Capture the open CNH;
CNH Front: Capture the front of the CNH;
CNH Back: Capture the back of the CNH;
RG Front: Capture the front of the RG;
RG Back: Capture the back of the RG;
Others: Capture any other document.
Create an instance of the builder (generated through the IAcessoBioBuilder
interface), providing the relevant context as a parameter and implementing the AcessoBioListener
class. The implementation of this class is quite simple and can be done with just a few lines of code. All you need to do is instantiate the builder, specifying the relevant context and overriding the callback methods with your application's business logic:
Note that the implementation of the AcessoBioListener
class largely consists of configuring the callback methods. Each method is called in a specific situation based on the SDK's return.
Override the methods exemplified above with your application’s business logic.
onErrorAcessoBio(ErrorBio errorBio)
This method is invoked with a parameter of type ErrorBio
that contains details about the error. Learn more about the ErrorBio
type in the error handling section.
onUserClosedCameraManually()
This method is invoked whenever the user manually closes the camera, such as by clicking the "Back" button.
onSystemClosedCameraTimeoutSession()
This method is invoked once the maximum session time is reached (without capturing any image).
You can configure the session timeout in seconds using setTimeoutSession
. The default and minimum timeout is 40 seconds.
onSystemChangedTypeCameraTimeoutFaceInference()
This method is invoked when the maximum time for face detection is reached without detection.
The maximum time is 13 seconds. The mode is then switched to manual capture to facilitate the user’s action.
All the above methods must be created as indicated in your project (even without any logic); otherwise, the project won’t compile successfully.
The implementation of these listener methods should be done through an instance of the iAcessoBioSelfie
class.
The camera opening method, which is called in the next step, needs to know what to do upon successfully capturing an image or encountering an error during the process. It is necessary to inform "what to do" to the camera opening method by implementing listeners that are called in success or error situations.
By configuring the listeners, you can specify what happens in your app in case of an error (method onErrorDocument
) or success (method onSuccessDocument
) in capturing images. The example below illustrates the configuration of the listeners, building, and opening the camera:
onSucessDocument
MethodWhen successfully capturing an image, this method is invoked and returns an object of type ResultCamera
, which is used later in the REST API requests:
The ResultCamera
object returns two attributes: base64
and encrypted
.
The base64
attribute can be used if you want to display a preview of the image in your app.
Both the encrypted
and base64
attributes can be sent in the REST API calls of the by Client.
If it is necessary to convert the base64 string to a bitmap, the standard method does not work for Android. You need to perform a split at the comma (,) for it to function correctly. If you want to learn more, read the article: How to convert a Base64 string into a Bitmap image to show it in a ImageView?.
onErrorDocument
MethodIf an error occurs during the image capture, this method is invoked and returns an object of type ErrorBio
:
Learn more about the types of ErrorBio
in the SDK's error handling section.
It is necessary to create an instance of the builder using the build()
method. This method is provided by the object generated with the IAcessoBioBuilder
interface and the AcessoBio
class:
The next step is to prepare the camera using the prepareDocumentCamera()
method with the object returned by the builder (named UnicoCheckCamera
in the example above). The prepareDocumentCamera()
method generates an object of type UnicoCheckCameraOpener.Document
, which is used to open the camera with its open()
method, receiving the type of document to be captured as a parameter:
If you need to capture a document for which there is no specific frame (e.g., RNE, among others), use the DocumentCameraType.None
frame, which will allow you to use a generic rectangular frame to guide any capture.
After capturing images, the next step is to send the generated base64
image from the SDK to the Client APIs.
Still need help?
Didn't find something or still need help? If you're already a client or partner, you can reach out through our Help Center.
Parameter | Description |
---|---|
DocumentCameraType.CPF
Capture the front of the CPF
DocumentCameraType.CNH
Capture the open CNH
DocumentCameraType.CNH_FRENTE
Capture the front of the CNH
DocumentCameraType.CNH_VERSO
Capture the back of the CNH
DocumentCameraType.RG_FRENTE
Capture the front of the RG
DocumentCameraType.RG_VERSO
Capture the back of the RG
DocumentCameraType.None
Capture any other document