Skip to main content

Android Integration

This guide will help you integrate the Facial Lite SDK into your Android application.

note

You can find sample project containing complete integration of SDK here.

Please follow these steps to integrate this framework.

Integration Guide

  • Add Face Recognition SDK to your app by updating your app/build.gradle
plugins {
id 'com.android.application'
}

android {
...
compileSdk 34
defaultConfig {
...
minSdk 26
targetSdk 34
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
repositories() {
maven {
url "s3://" + S3_BUCKET_ID
credentials(AwsCredentials) {
accessKey S3_ACCESS_KEY
secretKey S3_SECRET_KEY
}
}
}

}

dependencies {
...
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.fetchsky.facialrecognitionlitesdk:sdk:<version-code>'
...
}

Note: S3 Credentials will be provided separately

private void initializeSdk(String base64ImageString) {
Intent intent = new Intent(this, com.fetchsky.facialrecognitionlitesdk.MainActivity.class);
intent.putExtra("facialImage", base64ImageString);
startActivity(intent);

}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

initializeSdk("<Base64ImageString>");

IntentFilter filter = new IntentFilter();
filter.addAction("com.identity.ACTION_SEND_DATA");
registerReceiver(dataReceiver, filter, Context.RECEIVER_EXPORTED);
}

private final BroadcastReceiver dataReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.e("message", Objects.requireNonNull(intent.getAction()));
if ("com.identity.ACTION_SEND_DATA".equals(intent.getAction())) {
String type = intent.getStringExtra("type");
Bundle payload = intent.getBundleExtra("payload");
if (type != null && payload != null) {
... handle broadcast message here
}
}
}
};

@Override
protected void onDestroy() {
super.onDestroy();
// Unregister the BroadcastReceiver when not needed
unregisterReceiver(dataReceiver);
}

Theming

To customize the SDK colors, you can define the following color values in your colors.xml file and update them as needed:

<color name="facial_black">#FF000000</color>
<color name="facial_white">#FFFFFFFF</color>
<color name="facial_background">#FFFFFFFF</color>
<color name="facial_accent">#0283CA</color>