SDK Documentation
  • Welcome!
  • Document Capture
    • Overview
    • Android Native SDK
      • Installation Guide
      • Implementation Guide
      • SDK Response
    • iOS Native SDK
      • Installation Guide
      • Implementation Guide
      • SDK Response
    • React Native Plugin
      • Installation Guide
      • Implementation Guide
      • Plugin Response
    • Flutter Plugin
      • Installation Guide
      • Implementation Guide
      • Plugin Response
    • Cordova Plugin
      • Installation Guide
      • Implementation Guide
      • Plugin Response
    • Release Notes
      • 🟦Latest Patch Release
      • Minor Release - 12/09/2024
      • Major Release - 11/06/24
      • Minor Release - 07/03/24
      • Minor Release - 30/11/23
      • Minor Release - 17/08/23
      • Minor Release - 03/07/23
      • Minor Release - 15/06/23
      • Minor Release - 15/03/23
      • Major Release - 02/04/23
    • 🆕Coming Soon
  • Biometrics
    • Overview
    • Android Native SDK
      • Installation Guide
      • Implementation Guide
      • SDK Response
    • iOS Native SDK
      • Installation Guide
      • Implementation Guide
      • SDK Response
    • React Native Plugin
      • Installation Guide
      • Implementation Guide
      • Plugin Response
    • Flutter Plugin
      • Installation Guide
      • Implementation Guide
      • Plugin Response
    • Cordova Plugin
      • Installation Guide
      • Implementation Guide
      • Plugin Response
    • Release Notes
      • 🟦Latest Patch Release
      • Minor Release - 17/08/23
      • Minor Release - 03/07/23
      • Minor Release - 15/03/23
      • Major Release - 02/04/23
  • SDK Error Codes
  • Support
    • Contact Us
    • Legacy SDKs
Powered by GitBook
On this page
  • Authentication
  • Initialization
  • Configurations
  • Configurations Breakdown
  • SDK Event Logs
  • Start The SDK
  • Sample Integration Example
  1. Document Capture
  2. Android Native SDK

Implementation Guide

PreviousInstallation GuideNextSDK Response

Last updated 1 month ago

Authentication

A unique access token should be created upon each SDK entry. In order to generate an access token, please refer to Valify's Documentation.

Security Warning: For improved security, consider implementing the access token fetching logic outside the Activity. This helps keep sensitive credentials secure and reduces potential exposure within the Activity/Fragment code.

Initialization

Declare the following variables

private VIDVOCRConfig.Builder vidvOcrBuilder;

Initialize your SDK in your activity or fragment as follows

vidvOcrBuilder = new VIDVOCRConfig.Builder();

Configurations

The SDK builder is separated into two components.

Make sure that you fetched the access token successfully before passing it to the Builder object.

Required Configurations

vidvOcrBuilder
.setBaseUrl("Base Url"); //add your actual base URL
.setAccessToken("Access Token"); //add the fetched access token here
.setBundleKey("Bundle Key"); //add your actual bundle key

Optional Configurations

vidvOcrBuilder
.setLanguage(String) // "en" is set as default
.setDataValidation(boolean) // false is set as default
.setReturnValidationError(boolean) // false is set as default
.setReviewData(boolean) // default is true
.setPreviewCapturedImage(boolean) // default is false
.setManualCaptureMode(boolean) // default is false
.setHeaders(HashMap<String, String>()) // default is empty
.setSSLCertificate(Inputstream) // Inputstream for a certificate file, no default certificate
.setCaptureOnlyMode(boolean) // default is false
.setDocumentVerificationPlus(boolean) // default is false
.setCollectUserInfo(boolean) //enable/disable user information collection
.setAdvancedConfidence(boolean) // default is false
.setLogo(new VIDVLogo) // default is Valify's logo new VIDVLogo.Valify()
.setPrimaryColor(Color.parseColor("hexa_color")); // default is Valify’s primary color

Configurations Breakdown

This section shows the breakdown of all optional builder configurations.

  1. The following line is where the user interface language is set.

.setLanguage(String) // ["ar" or "en"] 

The currently supported languages are Arabic and English

  1. If the following line is set to true, an extra layer of validations is added to the SDK response.

.setDataValidation(boolean)
  1. If the following line is set to true, any validation exceptions raised on extracted NID data will be returned in the ServiceFailure instance.

.setReturnValidationError(boolean)
  1. If the following line is set to true, a screen is added to the user flow that displays the images captured and the OCR result to the user.

.setReviewData(boolean)
  1. If the following line is set to true, the captured image will be displayed for the user.

.setPreviewCapturedImage(boolean)
  1. If the following line is set to true, the SDK will automatically enable manual capture if it detects that the user is unable to auto capture card.

.setManualCaptureMode(boolean)
  1. The following line is optional and can be used to set any headers that may be required for purposes specific to your application. Any headers set will be sent along with each API call made by the SDK.

.setHeaders(HashMap<>())
  1. The following line is optional and can be used to set an SSL certificate that may be required for purposes specific to your application.

.setSSLCertificate(Inputstream)
  1. If the following line is set to true, the SDK purely performs image capturing and only returns these images in the SDK response.

.setCaptureOnlyMode(boolean) 
  1. If the following line is set to true, an extra layer of data amd visual validations is added to the SDK response.

.setDocumentVerificationPlus(boolean)
  1. If the following line is set to true then additional checks are made for NID fraud detection and the results are returned in the response.

.setAdvancedConfidence(boolean)
  1. If the following line is set to true then you need to enable the location permission to your application to use collect user info option

 .setCollectUserInfo(boolean)

add these lines to your app manifest

<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"tools:ignore="CoarseFineLocation" />

then add request location permission before calling SDK builder and make sure the permission is granted

if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
    //start SDK here
} else {
    requestPermissionLauncher.launch(Manifest.permission.ACCESS_FINE_LOCATION);
}
  1. Use the following line to customize the SDK logo

.setLogo(new VIDVLogo.ByteArrayLogo(image)) //for adding byte[] image as logo
.setLogo(new VIDVLogo.ResourceLogo(R.id.logo)) //for adding resource logo as sdk logo
.setLogo(new VIDVLogo.Empty()) //for disabling sdk logo
.setLogo(new VIDVLogo.Valify()) //for default valify's sdk logo
  1. The following line is optional and can be used to set your company's branding color to the SDK's user interface.

.setPrimaryColor(Color.parseColor("hexa_color")) // ex: ex:#62CBC9

SDK Event Logs

The following listener can be used to receive event logs from the SDK experience to be used for user behavior analysis.

vidvOcrBuilder.setLogsListener(new VIDVLogListener() {
                        	@Override
                        	public void onLog(VIDVEvent log) {
                            	Log.d("VIDV-Logs", 
                                    "Key: " + log.getKey() + ", " + 
                                    "Session ID: " + log.getSessionID() + ", " + 
                                    "Date: " + log.getDate() + ", " + 
                                    "Time Stamp: " + log.getTimestamp() + ", " +
                                    "Type: " + log.getType() + ", " +
                                    "Screen: " + log.getScreen() + ", " +
                                    );

                        	}

                        	@Override
                        	public void onLog(VIDVError log) {
                            	Log.d("VIDV-Error", 
                                        "Code: " + log.getCode() + ", " + 
                                        "Message: " + log.getMessage() + ", " + 
                                        "Session ID: " + log.getSessionId() + ", " + 
                                        "Date: " + log.getDate() + ", " + 
                                        "Time Stamp: " + log.getTimestamp() + ", " +
                                        "Type: " + log.getType() + ", " +
                                        "Screen: " + log.getScreen() + ", " +
                                                                            
                        	}
                    	});

Start The SDK

vidvOcrBuilder.start(MainActivity.this,vidvOcrListener); 

Sample Integration Example

You need first an instance of SDK's listener Use the following code snippet to run the SDK

Check out our for a simple integration app demonstrating how to use our SDK. The repository includes step-by-step instructions and sample code to help you get started quickly.

Authentication
GitHub repository
vidvOcrListener