Add the repository
maven { url 'https://public-n3.advai.net/repository/maven-releases/' }Add the dependencies in your project's gradle:
implementation 'ai.advance.mobile-sdk.android:global-iqa-lib:1.4.2'If your application has package size constraints or you need to reduce the app bundle size, you can optimize by excluding the model file module from the dependencies in step 2. This modification reduces the SDK package size by approximately 1MB. The model files will be downloaded automatically when users first launch the SDK. Please be aware that network connectivity issues may cause download failures.
implementation ('ai.advance.mobile-sdk.android:global-iqa-lib:1.4.2'){ exclude group: 'ai.advance.mobile-sdk.android', module: 'global-iqa-model'}Initialize the SDK
Add the following initialization code to the custom application
GlobalIQASDK.init(application);Check license.
The license is obtained by your server calling our openAPI, you need to check license before starting the IQA activity.
String license = "xxx";String checkResult = GlobalIQASDK.setLicenseAndCheck(license);if ("SUCCESS".equals(checkResult)) { // license valid startGlobalIQAActivity();} else { // license is not available, expired/wrong format/appId not filed}User binding (highly recommended).
You can use this method to pass us your unique user ID, and we will establish a mapping relationship based on that ID. It's easy to track logs with us in case of problems.
GlobalIQASDK.bindUser(String userId); Create GlobalIQAView in XML. Below is the suggested syntax.
It is recommended to set the view aspect ratio to 8:5.
<ai.advance.sdk.global.iqa.lib.GlobalIQAView android:id="@+id/iqa_view_lite_activity" android:layout_width="0dp" android:layout_height="0dp" app:layout_constraintDimensionRatio="H,8:5" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintWidth_percent="0.95" />Start in real-time scanning mode.
private void startScan() { ScanConfig scanConfig = new ScanConfig.Builder() .setCardSide(CardSide.FRONT) .setCardType(CardType.ID_CARD) .setRegion("IDN") .setScanTimeoutLimitSeconds(50) .build(); // Save this ID—it enables quick log identification when reporting issues to our support team. String eventId = mGlobalIQAView.startDetectionWithScan(scanConfig, new ScanCallback() {
@Override public void onAuthCheckStart() { // AAI authentication started. It is recommended to display 'auth loading' here. }
@Override public void onAuthCheckFinish(AuthResultData authResultData) { // AAI authentication ended. It is recommended to hide 'auth loading' here. boolean isSuccess = authResultData.success;// Whether the authentication was successful. String code = authResultData.code; String message = authResultData.message; }
@Override public void onUploadDataStart() { // Scan successful, starting to upload data. It is recommended to display 'upload loading' here. }
@Override public void onUploadDataFinish(UploadResultData uploadResultData) { // Data upload finished. It is recommended to display 'upload loading' here. boolean isSuccess = uploadResultData.success;// Whether the data upload was successful. boolean isPay = uploadResultData.isPay; // This indicates whether there is a charge. String transactionId = uploadResultData.transactionId; // transaction id String base64Image = uploadResultData.base64Image;// Base64 format image. Bitmap bitmapImage = uploadResultData.getBitmapFormatImage(); // Bitmap format image. }
@Override public void onRemainingSecondsChanged(int remainSeconds) { // Countdown timer for remaining scan time, unit: seconds. }
@Override public void onScanWarn(ImageWarnCode warnCode) { // Status codes during the scanning process. Here, display corresponding prompt messages based on different status codes. }
@Override public void onScanFailed(ErrorCode errorCode) { // Error codes for scanning errors. Receiving this callback indicates an exception occurred, making it impossible to continue scanning. At this point, the scan should be terminated. }
});}Start in manual photo mode.
private void startPhotoCaptureDetection() {
TakePhotoConfig takePhotoConfig = new TakePhotoConfig.Builder() .setCardSide(CardSide.FRONT) .setCardType(CardType.ID_CARD) .setRegion("IDN") .build();// Save this ID—it enables quick log identification when reporting issues to our support team. String eventId = mGlobalIQAView.startDetectionWithPhotoCapture(takePhotoConfig, new PhotoCaptureCallback() {
@Override public void onAuthCheckStart() { // AAI authentication started. It is recommended to display 'auth loading' here. }
@Override public void onAuthCheckFinish(AuthResultData authResultData) { // AAI authentication ended. It is recommended to hide 'auth loading' here. boolean isSuccess = authResultData.success;// Whether the authentication was successful. String code = authResultData.code; String message = authResultData.message; }
});}
// The user clicked the photo button, calling the View method to take a photo.private void takePhoto() { mGlobalIQAView.takePhoto(new TakePhotoCallback() { @Override public void onTakePhotoCaptureFinish(TakePhotoResultData takePhotoResultData) { boolean isSuccess = takePhotoResultData.success;// Indicates whether the photo was taken successfully. String code = takePhotoResultData.code; } });}// The user feels that the collected image is clear and usable, and chooses to use this image.private void usePhoto() { mGlobalIQAView.usePhoto(new UploadDataCallback() { @Override public void onUploadDataStart() { // Starting to upload data. It is recommended to display 'upload loading' here. }
@Override public void onUploadDataFinish(UploadResultData uploadResultData) { // Data upload finished. It is recommended to display 'upload loading' here. boolean isSuccess = uploadResultData.success;// Whether the data upload was successful. boolean isPay = uploadResultData.isPay; // This indicates whether there is a charge. String transactionId = uploadResultData.transactionId; // transaction id String base64Image = uploadResultData.base64Image;// Base64 format image. Bitmap bitmapImage = uploadResultData.getBitmapFormatImage(); // Bitmap format image. }
});}// The user feels that the quality of the collected image is poor and chooses to retake the photo.private void notUsePhoto() { mGlobalIQAView.notUsePhoto();}Stop Detection
// You can call the stopDetection() method after starting the detection (whether in scan mode or photo mode) to stop it.mGlobalIQAView.stopDetection();Destroy the GlobalIQAView.
// Please call destroy() to destroy the view and free up memory when the page is destroyed or when it is no longer in use.@Overrideprotected void onDestroy() { mGlobalIQAView.destroy(); super.onDestroy();}| WarnCode | Description | Suggested prompts |
|---|---|---|
| NO_CARD | No card detected. | No document is detected |
| TOO_SMALL_CARD | Card area is too small. | Document is too small |
| EDGE_CROSS | Card edges are incomplete. | The document is incomplete\nplease make sure the document in the center with the edges aligned |
| CARD_POOR_QUALITY | Low card quality: Dim/Blurred/Overexposed. | Document is too dim/blurred/overexposed |
| CARD_OCCLUDED | Card area is occluded. | Please keep your ID card unobstructed |
| GOOD | Card quality is acceptable. | Please hold the phone steadily |
See FAQ