Install Document Scan SDK for Android
There are multiple steps to complete in order to install the Document Scan for Android SDK.
Add Dependencies
The Document Scan 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-document:1.1.0")
}
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 to your application's strings.xml file:
Copy<string name="AIDLicenseKey" translatable="false">Your license key</string>
(OR)
-
Set the key programmatically using a method on DSCapture:
Copy// Kotlin
val dsCaptureInstance = DSCapture(this) // pass in your ApplicationContext
dsCaptureInstance.setLicense(key: "Your provided license Key")
Configure Required Permissions
The end-user must grant permission to use the camera before beginning a document capture session. The SDK may also optionally collect user location data, which requires granted location permissions.
Camera Permission
Before you can request permission for the device camera, you need to 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
Before you can request permission for the user's location, you need to make 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
)
}
}