Requirements
Android SDK 21 (LOLLIPOP) or higher and includes Google Play Services
Download & Install the Library
Download the AndiaAndroid zip from this Github link
Unzip the Folder AndiaAndroid.zip
Import the file andia-selfie.aar into your project in Android Studio
Click File > New > New Module.
Enter the location of the library then click Finish.
Right click on the new app folder and select Open Module Settings
In Dependencies, select Add Module Dependency, and then select the imported Selfie Module.
Add Google Play Services
In your build.gradle file (project level) add google Services :
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.0.1' //<--- ADD HERE
}
}
allprojects {
repositories {
google()
jcenter()
}
}
.......
Add Dependencies
In your build.gradle file (App level) add the following lines
implementation 'com.google.firebase:firebase-ml-vision:16.0.0'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.loopj.android:android-async-http:1.4.9'
implementation project(':andia-debug')
//########### Example App build.gradle .
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.beto.andiaexample"
minSdkVersion 22
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':andia-debug')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-ml-vision:16.0.0'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.loopj.android:android-async-http:1.4.9'
implementation project(':andia-debug')
}
Update the Manifest file
Add the following settings to the manifest.xml file
<uses-feature android:name="android.hardware.camera" android:required="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<meta-data android:name="com.google.firebase.ml.vision.DEPENDENCIES" android:value="face" />
Using the Library
Import the classes in your Activity
import io.andia.example.ResultOnboarding;
import io.andia.example.SelfieValidator;
import io.andia.example.SelfieCallback;
import io.andia.example.ResultValidation;
In your Main Activity implement SelfieCallback
public class MainActivity extends AppCompatActivity implements SelfieCallback {
//activity Code
// ...
//Callback for OnBoarding.
@Override
public void resultOnBoarding(ResultOnboarding result) {
Log.d("ANDIA", result.getMessage());
}
//Callback for Validation.
@Override
public void resultValidation(ResultValidation result){
Log.d("ANDIA", result.getMessage());
}
}
Call the OnBoarding Method.
onboardingButton = (Button) findViewById(R.id.buttonOnboard);
onboardingButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
SelfieValidator validator = new SelfieValidator();
validator.onboarding("API_KEY", MainActivity.this);
}
});
Call the Validation Method
validateButton = (Button) findViewById(R.id.buttonValidate);
validateButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
SelfieValidator validator = new SelfieValidator();
validator.validation("API_KEY", "userid", MainActivity.this);
}
});
Download Example
Example Project in this Github Link