Install Selfie Capture SDK for Android
Add Dependencies
The Selfie Capture for Android SDK is available on Maven and can be included via Gradle.
Add the SDK as a dependency to your app-level build.gradle:
dependencies {
implementation("com.authenticid:aid-selfie:1.0.1")
}
Add License Key
The SDK will not run without a valid license key provided by HID. You can assign this key in one of two ways:
-
Add the following code to your application's strings.xml file:
Copy<string name="AIDLicenseKey" translatable="false">LICENSE KEY</string>
-
Use a method on SelfieCapture:
// Kotlin
val selfieCaptureInstance = SelfieCapture(this) // pass in your ApplicationContext
selfieCaptureInstance.setLicense(key: "LICENSE KEY")
Configure Permissions
You can configure permissions for camera and location access. For more information, refer to the Android developer documentation on requesting permissions.
Camera Permission
Requesting permission for use of the device camera requires that you make usage declarations in AndroidManifest.xml:
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera.any"/>
You can then request camera permissions from the end-user:
val CAMERA_PERMISSION_REQUEST_CODE = 88
fun requestCameraPermissions() {
if (ContextCompat.checkSelfPermission(
this,
android.Manifest.permission.CAMERA
) != PackageManager.PERMISSION_GRANTED
) {
ActivityCompat.requestPermissions(
this,
arrayOf(android.Manifest.permission.CAMERA),
CAMERA_PERMISSION_REQUEST_CODE
)
}
}
Location Permission
Access to the end-user's geolocation is optional and should only be requested when necessary. Requesting this access requires you set one or two usage declarations in AndroidManifest.xml, depending on which type of access is needed:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
You can then request location permissions from the end-user:
val LOCATION_PERMISSION_REQUEST_CODE = 89
fun requestLocationPermissions() {
if (ContextCompat.checkSelfPermission(
this,
android.Manifest.permission.ACCESS_FINE_LOCATION
) != PackageManager.PERMISSION_GRANTED
) {
ActivityCompat.requestPermissions(
this,
arrayOf(android.Manifest.permission.ACCESS_FINE_LOCATION),
LOCATION_PERMISSION_REQUEST_CODE
)
}
}