Documentation

Integration

Integration Documentation for Android Compatible with Liveness Detection V4.x Version.

Overview

  • Minimum Android version:4.4 (API Level:19)
  • Compilation Android SDK version:API Level:35
  • Target Android SDK version:API Level:35
  • Supported CPU architectures:armeabi-v7a,arm64-v8a
  • SDK incremental package size:4.5MB+

    If you have requirements for package size, you can refer to this to reduce the package size by approximately 1.4MB.

  • Capture image size:default capture image resolution 600px*600px, size is about 300KB, support custom image size range: 300px~1000px
  • Supported languages:
    • English
    • Indonesian
    • Vietnamese
    • Chinese
    • Hendi
    • Thai
    • Spanish
  • Use-permissions:
    <uses-feature android:name="android.hardware.camera" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CAMERA" />

Compliance Explanation

Click to view the compliance explanation

Release Notes

Click to show release notes

Demo

Method 1

Install IDV-Demo.apk to your phone and log in with the test account.

Method 2:

Download Demo Project

Migration Guides

If you are upgrading from an older version of the Liveness SDK, please refer to this document to understand the changes.

Installation

Simple Mode

If you want to quickly integrate the SDK and you don't have any customization requirements for the UI part, you can follow the steps below for the dependency:

  1. Add the repository
     maven { url 'https://public-n3.advai.net/repository/maven-releases/' }
  2. Add the dependencies in your project's gradle:
    implementation 'ai.advance.mobile-sdk.android:liveness-detection-ui:4.0.0'
    implementation 'ai.advance.mobile-sdk.android:liveness-detection:4.0.0'

Source Code

We provide you with the source code for the UI module. You can adjust this part of the code according to your project's architecture. Please ensure you understand the UI module code before making any modifications to avoid causing unexpected program execution issues.

Usage

  1. Initialization SDK.

    The init method need to be called in your application class

    // If you have subscribed to the Global liveness service, then you need to set the last boolean value to true, otherwise please set it to false.
    GuardianLivenessDetectionSDK.init(this,your market,false);
  2. Check license

    The license is obtained by your server calling our openAPI, you need to check license before starting the liveness detection activity.

    String license = "xxx";
    String checkResult = GuardianLivenessDetectionSDK.setLicenseAndCheck(license);
    if ("SUCCESS".equals(checkResult)) {
        // license valid
       startLivenessActivity();
    } else {
      // license is not available, expired/wrong format/appId not filed
    }
    
    The returned values of checkResult:
    
    APPLICATION_ID_NOT_MATCH: The package name is not within the authorized scope, please check your package name.
    
    LICENSE_EXPIRE: The license has expired, please confirm that the user has calibrated the phone time.
    
    ERROR_LICENSE(1): The license parsing succeeded, but necessary authentication information is missing, this case generally will not occur.
    
    ERROR_LICENSE(2): The license parsing succeeded, but the internal format is incorrect, this case also generally will not occur.
    
    ERROR_LICENSE(3): It is highly likely that an incompatible SDK license is being used, such as using an IQA license for liveness detection.
    
    ERROR_LICENSE(4, 5): Parsing failed, please check if the license has issues like mismatched quotes, line breaks, etc.
  3. You can create SDK launch parameters using the method below.
    For valid values of livenessType, pleaserefer to this link.

    LivenessConfig configs = new LivenessConfig.Builder()
                    .setCameraType(CameraType.FRONT)// FRONT or BACK camera
                    .setQueryId(queryId)// In ticket authentication mode, you need to pass the queryId,other authentication modes do not require it.
      							.setTicket(ticket)// In ticket authentication mode, you need to pass the ticket,other authentication modes do not require it.
                    .setDetectOcclusion(false)// Set whether to enable occlusion detection. It is false by default.
                    .setAuditImageConfig(new AuditImageConfig // Audit image configs
                            .AuditImageConfigBuilder()
                            .setEnableCollectSwitch(true) // Set whether to enable audit image collection. It is false by default.
                            .setImageWidth(400)// The width of audit images
                            .setImageQuality(30)// The quality of audit images,must in [30,100].It is 30 by default.
                            .setRelativeSecondsCaptureAfterCameraLaunched(3f)// If you want to collect images relative to the camera's open time, you can set the relative time here (unit: seconds).
                            .build())
                    .setLivenessType("your liveness type")// Set the liveness type
                    .setSignatureId("your signature id")// Set the signatureId
                    .setMaskColor(Color.GREEN))// Set the LivenessView mask color
                    .setOvalColor(Color.GREEN)// Set the oval light color
                    .setOvalNormalColor(Color.GRAY)// Set the oval normal color
                    .setDistantNearTimeout(50_000) // Set the timeout limit of Distant-Near liveness stage
                    .setSilentTimeout(50_000)// Set the timeout limit of Silent liveness stage
                    .setActionTimeout(10_000)// Set the timeout limit for each action.
                    .setPrepareMillSeconds(0)// Set the waiting time before starting liveness detection (during this stage, the client can perform UI interactions to prompt the user to get ready).
                    .setResultPictureSize(600)// Customize the size of the returned image,Settable input range: [300,1000], unit: pixels.It is 600 by default.
                    .setMaxRecordVideoSeconds(600)// Set the maximum duration for video recording in seconds,unit:seconds,If set to 0, it means no video will be recorded.
                    .setUserId("your unique user id")// You can use this method to pass your user unique identifier to us, we will establish a mapping relationship based on the identifier.It is helpful for us to check the log when encountering problems.
                    .build();
  4. Start liveness detection

    public class SomeActivity extends Activity{
    
        /**
         * requestCode
         */
        public static final int REQUEST_CODE_LIVENESS = xxxx;
    
        /**
         * start Liveness Activity
         */
        private void startLivenessActivity() {
          Intent intent = new Intent(this, LivenessActivity.class);
    			intent.putExtra(LivenessActivity.EXTRA_CONFIGS, configs);
          startActivityForResult(intent, REQUEST_CODE_LIVENESS);
      }
    
      /**
       * get Liveness result
       */
      @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
          if (requestCode == REQUEST_CODE_LIVENESS) {
            // Please make sure to save eventId for contacting us for troubleshooting purposes
            String eventId = LivenessResult.getEventId();
            File videoFile = LivenessResult.getVideoFile(this);// The video file
            if (LivenessResult.isSuccess()) {// Success
              String livenessId = LivenessResult.getLivenessId();// livenessId
              boolean pay = LivenessResult.isPay();// pay status
              Bitmap livenessBitmap = LivenessResult.getLivenessBitmap();// picture(Far)
              Bitmap nearBitmap = LivenessResult.getNearBitmap();// picture(Near)
              List<LivenessImageData> auditImageList = LivenessResult.getAuditImageList();// Audit images
            } else {// Failure
              String errorCode = LivenessResult.getErrorCode();// error code
              String errorMsg = LivenessResult.getErrorMsg();// error message
                ...
            }
          }
        }
      }
    

Error Code

See Error Code

FAQ

See FAQ