# Android Active Liveness Online

Build Status Build Status Licence

# 📜 Introduction

Documentation below will help you in integrating the Online Active Liveness SDK to your own Android Application.

Reading Time: 4 min read

# 🔧 How it works ?

LivenessSDK is based on the Gesture detection of the user. Users will be directed to perform facial gestures such as Blink, Nod etc and expected to be performed within a set period of time. The trueness of the Action is then evaluated to verify live users.

# What can I use Liveness SDK for ?

Ensure Secure use of your application by determining liveness of your users.

# 📚 Documentation

  • Step 1: Sign up for a developer account through FaceX User Portal
  • Step 2: Navigate to Plans & Payments Tab & Select Plans
  • Step 3: Purchase a plan matching your requirement from the Online Active Liveness SDK
  • Step 4: Navigate to Mobile SDK Tab & Select License History
  • Step 5: Download the json file for Android SDK from the online license Section
  • Step 6: Download the Online Active Livenesss Android SDK from this Github LivenessSDKOnline
  • Step 7: Add the JSON file from the portal to your project.

# 📲 Installation

  • Requires Java8 support/ gradle plugin 3+
  • Supports Android 5.0+

# Using AAR (Android Archive)

An AAR file contains a software library used for developing Android apps. It is structurally similar to an . APK file (Android Package), but it allows a developer to store a reusable component that can be used across multiple different apps. To integrate AAR into your android project:

  • Purchase Active Liveness SDK license from facex portal.
  • Download the file.json config file from the portal. Make sure file name is file.json.
  • Create assets directory in the android project ( if not already there) and copy the downloaded file.json to assets directory.
  • Download the latest liveness.aar release from here.
  • Open android studio and add the liveness SDK to your android project
    • Click File > New > New Module.
    • Click Import .JAR/.AAR Package from repo directory then click Next.
    • Enter the location of the liveness.aar file in the cloned directory then click Finish
  • Make sure the library is listed at the top of your settings.gradle file, as shown here for a library named "liveness":
    • include ':app', ':liveness'
  • Open the app module's build.gradle file and add a new line to the dependencies block as shown in the following snippet:
     implementation project(":liveness") 
     implementation 'com.google.android.gms:play-services-vision:20.0.0'

# 🐒 How to use

  • Make sure to get the camera permission.
if (ContextCompat.checkSelfPermission(
            ) != PackageManager.PERMISSION_GRANTED
        ) {

            if (ActivityCompat.shouldShowRequestPermissionRationale(
            ) {

            } else {

override fun onRequestPermissionsResult(requestCode: Int,
                                            permissions: Array<String>, grantResults: IntArray) {
        when (requestCode) {
            1 -> {
                // If request is cancelled, the result arrays are empty.
                if ((grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED)) {
//                    liveness.startLiveness()


# Kotlin

import io.facex.liveness.Liveness  
import io.facex.liveness.LivenessListener

class MainActivity : AppCompatActivity(),LivenessListener{
private lateinit var liveness: Liveness

 override fun livenessError(live: Boolean?, errorMessage: String?) {   

override fun livenessSuccess(live: Boolean?,bitmap : Bitmap) {  
override fun onCreate(savedInstanceState: Bundle?) {
	liveness= Liveness(this, R.id.fragment_holder)

# Java

import io.facex.liveness.Liveness  
import io.facex.liveness.LivenessListener

public class Mainactivity extends AppCompatActivity implements LivenessListener{
  private Liveness liveness;

  public void livenessError(Boolean live,String errorMessage){


  public void livenessSuccess(Boolean live,Bitmap bitmap){    

  protected void onCreate(Bundle savedInstanceState) {
      liveness= new Liveness(this, R.id.fragment_holder);
# layout file for fragment
liveness.startLiveness() creates a fragment, so it needs a view to bind the fragment.
Pass in the id of the fragment container using the liveness constructor.
eg: fragment_holder

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"


# Interfaces

# LivenessListener


override fun livenessSuccess(live: Boolean?,bitmap : Bitmap) {
 override fun livenessError(live: Boolean?, errorMessage: String?) {

  public void livenessError(Boolean live,String errorMessage){


  public void livenessSuccess(Boolean live,Bitmap bitmap){    

# 🎛 Customization

You can set some properties for liveness.

# Steps

Steps Value Default
Eyes Boolean true
Smile Boolean true
Yaw Boolean true
Random Boolean true

# Thresholds

Property Values Default
eyeThreshold 0.4 ... 0.6 0.5
smileThreshold 0.1 ... 0.8 0.7
stepTimerSeconds Seconds 5 seconds
maxTimerSeconds Seconds 15 seconds

# Localization

  • strings.xml
    <string name="camera_error">Camera Error</string>
    <string name="powered_by">Powered by</string>
    <string name="thank_you">Thank You</string>
    <string name="please_blink">Please Blink</string>
    <string name="please_smile">Please Smile</string>
    <string name="turn_head">Turn your head left and right</string>
    <string name="face_align">Keep your face within the box</string>

# 📋 Supported OS & SDK Versions

  • Android 6.0+
  • Java 8

# 👮🏻 License

Last Updated: 5/12/2020, 3:05:31 PM