K
K
Kvalifika
Search…
Android
Guide for integrating Kvalifika SDK into a native Android project
Use Kvalifika SDK to easily integrate into a native Android project. Before integrating Kvalifika, it is recommended to follow the steps described in Integration Guide and Initial Setup.
Naming of the properties and functions might be slightly modified depending on the version.

Installation

Add the following to the project's main build.gradle file:
Kotlin
Java
1
allprojects {
2
repositories {
3
// Existing repositories, like google() and jcenter()
4
maven { url 'https://s3.eu-central-1.amazonaws.com/com.kvalifika.sdk' }
5
}
6
}
Copied!
1
allprojects {
2
repositories {
3
// Existing repositories, like google() and jcenter()
4
maven { url 'https://s3.eu-central-1.amazonaws.com/com.kvalifika.sdk' }
5
}
6
}
Copied!
Please use minSdkVersion 21 in your build.gradle (Module) file
To install Kvalifika Android SDK, add the following to build.gradle (Module) file:
Kotlin
Java
1
dependencies {
2
// Insert line below to include our client library as a dependency.
3
implementation 'com.kvalifika:sdk:0.7.0'
4
}
Copied!
1
dependencies {
2
// Insert line below to include our client library as a dependency.
3
implementation 'com.kvalifika:sdk:0.7.0'
4
}
Copied!

Initialize the SDK

import Kvalifika:
1
import com.kvalifika.sdk.KvalifikaSDK
2
import com.kvalifika.sdk.KvalifikaSDKLocale
3
import com.kvalifika.sdk.KvalifikaSDKCallback
4
import com.kvalifika.sdk.KvalifikaSDKError
Copied!
After that, you need to initialize SDK with your appId and secretKey
appId is Application ID and secretKey is Application Secret Key, generated from Admin Panel. See Initial Setup for details.
Kotlin
Java
1
class MainActivity : AppCompatActivity() {
2
private lateinit var sdk: KvalifikaSDK
3
private val appId: String = "YOUR APP ID"
4
5
override fun onCreate(savedInstanceState: Bundle?) {
6
super.onCreate(savedInstanceState)
7
setContentView(R.layout.activity_main)
8
9
sdk = KvalifikaSDK.Builder(this, appId)
10
.locale(KvalifikaSDKLocale.EN)
11
.build()
12
}
13
}
Copied!
1
public class MainActivity extends AppCompatActivity {
2
private KvalifikaSDK sdk;
3
4
@Override
5
protected void onCreate(Bundle savedInstanceState) {
6
super.onCreate(savedInstanceState);
7
8
String appId = "YOU APP ID";
9
setContentView(R.layout.activity_main);
10
11
sdk = new KvalifikaSDK.Builder(this, appId)
12
.locale(KvalifikaSDKLocale.EN)
13
.build();
14
}
15
}
Copied!

Start Verification

Call sdk.startSession() on button click event:
Kotlin
Java
1
class MainActivity : AppCompatActivity() {
2
private lateinit var sdk: KvalifikaSDK
3
private val appId: String = "YOUR APP ID"
4
5
override fun onCreate(savedInstanceState: Bundle?) {
6
super.onCreate(savedInstanceState)
7
setContentView(R.layout.activity_main)
8
9
sdk = KvalifikaSDK.Builder(this, appId)
10
.locale(KvalifikaSDKLocale.GE)
11
.build()
12
13
}
14
15
// Start verification on button click
16
fun onVerificationPress(view: View?) {
17
sdk.startSession()
18
}
19
}
Copied!
1
public class MainActivity extends AppCompatActivity {
2
private KvalifikaSDK sdk;
3
4
@Override
5
protected void onCreate(Bundle savedInstanceState) {
6
super.onCreate(savedInstanceState);
7
8
String appId = "YOU APP ID";
9
setContentView(R.layout.activity_main);
10
11
sdk = new KvalifikaSDK.Builder(this, appId)
12
.locale(KvalifikaSDKLocale.EN)
13
.build();
14
}
15
16
public void onVerificationPress(View view) {
17
sdk.startSession();
18
}
19
}
Copied!

Handling Verifications

It's useful to know that whether a user has completed the verification flow or canceled it. For this, you can implement the callback methods.

Callback Methods

Method
Description
onInitialize
This callback method is triggered when SDK is initialized.
onStart
This callback method is triggered when the user starts verification.
onFinish
This callback method is triggered when the user completes verification. Get session data here.
onError
This callback method is triggered on error (see Error Codes for more information)
Kotlin
Java
1
sdk.callback(object : KvalifikaSDKCallback {
2
override fun onInitialize() {
3
Log.d("MainActivity", "initialized")
4
}
5
6
override fun onStart(sessionId: String) {
7
Log.d("MainActivity", "started")
8
}
9
10
override fun onFinish(sessionId: String) {
11
// Fetch session data here from your server
12
}
13
14
override fun onError(error: KvalifikaSDKError, message: String?) {
15
if(error == KvalifikaSDKError.INVALID_APP_ID) {
16
Log.d("MainActivity", "Invalid App ID")
17
}
18
19
if (error == KvalifikaSDKError.USER_CANCELLED) {
20
Toast.makeText(applicationContext, "User cancelled", Toast.LENGTH_LONG).show()
21
}
22
23
if (error == KvalifikaSDKError.TIMEOUT) {
24
Toast.makeText(applicationContext, "Timeout", Toast.LENGTH_LONG).show()
25
}
26
27
if (error == KvalifikaSDKError.SESSION_UNSUCCESSFUL) {
28
Toast.makeText(applicationContext, "Session failed", Toast.LENGTH_LONG).show()
29
}
30
31
if (error == KvalifikaSDKError.ID_UNSUCCESSFUL) {
32
Toast.makeText(applicationContext, "ID scan failed", Toast.LENGTH_LONG).show()
33
}
34
35
if (error == KvalifikaSDKError.CAMERA_PERMISSION_DENIED) {
36
Toast.makeText(applicationContext, "Camera permission denied", Toast.LENGTH_LONG).show()
37
}
38
39
if (error == KvalifikaSDKError.LANDSCAPE_MODE_NOT_ALLOWED) {
40
Toast.makeText(applicationContext, "Landscape mode is not allowed", Toast.LENGTH_LONG).show()
41
}
42
43
if (error == KvalifikaSDKError.REVERSE_PORTRAIT_NOT_ALLOWED) {
44
Toast.makeText(applicationContext, "Reverse portrait is not allowed", Toast.LENGTH_LONG).show()
45
}
46
47
if (error == KvalifikaSDKError.FACE_IMAGES_UPLOAD_FAILED) {
48
Toast.makeText(applicationContext, "Could not upload face images", Toast.LENGTH_LONG).show()
49
}
50
51
if (error == KvalifikaSDKError.DOCUMENT_IMAGES_UPLOAD_FAILED) {
52
Toast.makeText(applicationContext, "Could not upload Id card or passport images", Toast.LENGTH_LONG).show()
53
}
54
55
if (error == KvalifikaSDKError.NO_MORE_ATTEMPTS) {
56
Toast.makeText(applicationContext, "You have reached maximum attempts", Toast.LENGTH_LONG).show()
57
}
58
59
if (error == KvalifikaSDKError.UNKNOWN_INTERNAL_ERROR) {
60
Toast.makeText(applicationContext, "Unknown error happened", Toast.LENGTH_LONG).show()
61
}
62
}
63
})
Copied!
1
sdk.callback(new KvalifikaSDKCallback() {
2
@Override
3
public void onInitialize() {
4
Log.d("MainActivity", "initialized");
5
}
6
7
@Override
8
public void onStart(@NotNull String sessionId) {
9
Log.d("MainActivity", "started");
10
}
11
12
@Override
13
public void onFinish(@NotNull String sessionId) {
14
Log.d("MainActivity", "finished");
15
}
16
17
@Override
18
public void onError(@NotNull KvalifikaSDKError error, String message) {
19
if (error == KvalifikaSDKError.INVALID_APP_ID) {
20
Log.d("MainActivity", "Invalid App ID");
21
}
22
23
if (error == KvalifikaSDKError.USER_CANCELLED) {
24
Toast.makeText(getApplicationContext(), "User cancelled", Toast.LENGTH_LONG).show();
25
}
26
27
if (error == KvalifikaSDKError.TIMEOUT) {
28
Toast.makeText(getApplicationContext(), "Timeout", Toast.LENGTH_LONG).show();
29
}
30
31
if (error == KvalifikaSDKError.SESSION_UNSUCCESSFUL) {
32
Toast.makeText(getApplicationContext(), "Session failed", Toast.LENGTH_LONG).show();
33
}
34
35
if (error == KvalifikaSDKError.ID_UNSUCCESSFUL) {
36
Toast.makeText(getApplicationContext(), "ID scan failed", Toast.LENGTH_LONG).show();
37
}
38
39
if (error == KvalifikaSDKError.CAMERA_PERMISSION_DENIED) {
40
Toast.makeText(getApplicationContext(), "Camera permission denied", Toast.LENGTH_LONG).show();
41
}
42
43
if (error == KvalifikaSDKError.LANDSCAPE_MODE_NOT_ALLOWED) {
44
Toast.makeText(getApplicationContext(), "Landscape mode is not allowed", Toast.LENGTH_LONG).show();
45
}
46
47
if (error == KvalifikaSDKError.REVERSE_PORTRAIT_NOT_ALLOWED) {
48
Toast.makeText(getApplicationContext(), "Reverse portrait is not allowed", Toast.LENGTH_LONG).show();
49
}
50
51
if (error == KvalifikaSDKError.FACE_IMAGES_UPLOAD_FAILED) {
52
Toast.makeText(getApplicationContext(), "Could not upload face images", Toast.LENGTH_LONG).show();
53
}
54
55
if (error == KvalifikaSDKError.DOCUMENT_IMAGES_UPLOAD_FAILED) {
56
Toast.makeText(getApplicationContext(), "Could not upload Id card or passport images", Toast.LENGTH_LONG).show();
57
}
58
59
if (error == KvalifikaSDKError.NO_MORE_ATTEMPTS) {
60
Toast.makeText(getApplicationContext(), "You have reached maximum attempts", Toast.LENGTH_LONG).show();
61
}
62
63
if (error == KvalifikaSDKError.UNKNOWN_INTERNAL_ERROR) {
64
Toast.makeText(getApplicationContext(), "Unknown error happened", Toast.LENGTH_LONG).show();
65
}
66
}
67
});
Copied!

Error Codes

Error Code
Description
INVALID_APP_ID
Kvalifika App Id is incorrect
USER_CANCELLED
User canceled before completing verification.
TIMEOUT
Canceled due to inactivity.
SESSION_UNSUCCESSFUL
The Session was not performed successfully
ID_UNSUCCESSFUL
The ID Scan was not performed successfully and identity document data was not generated.
CAMERA_PERMISSION_DENIED
Camera is required but access is prevented by user settings.
LANDSCAPE_MODE_NOT_ALLOWED
Verification was canceled because the device is in landscape mode.
REVERSE_PORTRAIT_NOT_ALLOWED
Verification was canceled because the device is in reverse portrait mode.
FACE_IMAGES_UPLOAD_FAILED
Could not upload face images. Internal request failed.
DOCUMENT_IMAGES_UPLOAD_FAILED
Could not upload ID card or passport images. Internal request failed.
NO_MORE_ATTEMPTS
User has reached maximum limit of attempts
UNKNOWN_INTERNAL_ERROR
Session failed because of an unhandled internal error.

UI Customizations

Appearance

It is possible to customize the logo and icons and provide drawable resources.
Kotlin
Java
1
sdk = KvalifikaSDK.Builder(this, appId, secretKey)
2
.locale(KvalifikaSDKLocale.EN)
3
.logo(R.drawable.logo)
4
.documentIcon(R.drawable.document_icon)
5
.activeFlashIcon(R.drawable.flash_on)
6
.inactiveFlashIcon(R.drawable_flash_off)
7
.cancelIcon(R.drawable.cancel_icon)
8
.build()
Copied!
1
sdk = KvalifikaSDK.Builder(this, appId, secretKey)
2
.locale(KvalifikaSDKLocale.EN)
3
.logo(R.drawable.logo)
4
.documentIcon(R.drawable.document_icon)
5
.activeFlashIcon(R.drawable.flash_on)
6
.inactiveFlashIcon(R.drawable_flash_off)
7
.cancelIcon(R.drawable.cancel_icon)
8
.build()
Copied!

Language

It is possible to set locale when initializing SDK. Supported locales are:
Code
Language
EN
English
GE
Georgian
RU
Russian
SP
Spanish
Kotlin
Java
1
sdk = KvalifikaSDK.Builder(this, appId, secretKey)
2
.locale(KvalifikaSDKLocale.EN)
3
.build()
Copied!
1
KvalifikaSDK sdk = new KvalifikaSDK.Builder(this, appId, secretKey)
2
.locale(KvalifikaSDKLocale.EN)
3
.build();
Copied!

Development Mode

Without specifying mode SDK uses https://api.kvalifika.com
With development mode ON SDK uses https://apistaging.kvalifika.com
Kotlin
Java
1
sdk = KvalifikaSDK.Builder(this, appId)
2
.development(true)
3
.build()
Copied!
1
KvalifikaSDK sdk = new KvalifikaSDK.Builder(this, appId)
2
.development(true)
3
.build();
Copied!

ProGuard

If you are using ProGuard in the release build, add the following options:
1
-keep class com.facetec.sdk.** { *; }
Copied!