Android SDK
Information about the Android SDK
The Android SDK includes a core native library (closed-source) and a reference UI implementation provided in source code format. This setup allows you to fully customize the UI according to your application’s requirements. While this page provides an overview, you can read more detailed documents at Android SDK Documentation. The reference UI is written in Kotlin, however SenseCrypt Android SDK can be used in Java as well.
The Android SDK comes in two variants:
- Online: This variant is small in size, but it needs to connect with the server for SensePrint eID verification/decryption.
- Offline: This variant larger in size, but it can be used to verify/decrypt SensePrint eIDs with no network connectivity and completely on a mobile device.
Both variants utilize the same reference UI implementation. This means the same Kotlin source code is used for both variants. In the provided Android project you can use the following gradle task to switch between the variants:
// to set the project into online mode
./gradlew setSDKmode -Pmode=online
// to set the project into offline mode
./gradlew setSDKmode -Pmode=offlineThis gradle task updates the project's dependencies, app name, application id, app icons and changes the Constants for the respective variant. After performing a gradle sync the app can be build in the selected variant.
Note:
## SDK Initialization Requirements
To run the project and initialize the SDK, please use NDK version 26.1.10909125,
as the AAR files are built with this version.Constants
The Constants class contains different app-wide configuration values that can customize the flow of the app. The following are notable constants for customization:
Common to both online/offline SDKs
GENERATION_CAPTURE_MODE- the face capture method used while generating a SensePrint. Can be one ofFaceCaptureMode.ActiveCaptureFrontCamera,FaceCaptureMode.PassiveCaptureFrontCamera, orFaceCaptureMode.PassiveCaptureBackCamera.VERIFICATION_CAPTURE_MODE- the face capture method used while verifying a SensePrint. Can be one ofFaceCaptureMode.ActiveCaptureFrontCamera,FaceCaptureMode.PassiveCaptureFrontCamera, orFaceCaptureMode.PassiveCaptureBackCamera.SENSEPRINT_VERIFIER_AUTH_KEY- It is possible to generate SensePrint eID QR codes targeted at a specific verifier. See the section on Generating your first SensePrint eID QR. When theverifiers_auth_keyattribute is specified while generating the QR, that QR code can only be read by a specific verifier. Set the value ofSENSEPRINT_VERIFIER_AUTH_KEYto the value you used forverifiers_auth_keywhile generating the QR code.SDK_MODE- whether the current SDK mode is Offline or Online (as changed by the gradle task)DEBUG_FOR_SAVING_IMAGES- if turned on images are saved to Phone Storage for debug purposes.CONFIG_JSON_FILE_NAME- Json File to load the config from.
Online SDK
API_SERVER_URL- this value should point to your server that you deployed using the Docker. If you exposed the server usingngrokuse the Ngrok URL value.- AUTH_HEADER - this value should be set to the
mobile_api_keyvalue you used in thesecrets.jsonfile while starting the Docker container for the server. If you are using a JWT Token for mobile authorization, this should be set toBearer your_jwt_token_from_server Download_URL_FOR_FR_N_BIN_MODEL- URL to download the model.
Offline SDK
ISSUERS_PUBLIC_KEY- this value is present only in the offline SDK. If you started the server in Certificate Authority mode by setting theissuers_private_key, then the server will issue signed SensePrints. In order to verify them, you must set the correspondingISSUERS_PUBLIC_KEYin the Constants. For more information checkout our overview.LIVENESS_THRESHOLD- this value defines the threshold of the IDRND liveness check performed on device in offline mode. Default is 0.5.LIVENESS_TOLERANCE- tolerance of th IDRND liveness. Default is REGULAR.LIVENESS_PIPELINE- IDRND liveness pipeline that should be used. Default is pegasus.
Important Activities
-
SplashActivity
Responsible for initializing the SDK and loading the necessary Machine Learning models into memory.
The SplashActivity culminates by loading the MainActivity. -
MainActivity
A simple interface displaying entry points for SensePrint eID QR generation, verification and reading. Users can interact with buttons to proceed with either operation. -
QRScanActivity
This activity can be invoked with or without intent extras.
When invoked without any extras, the activity will interpret the launch as an attempt to capture QR data that will subsequently be decrypted via a face scan.
Based on the capture type which is set up inConstants.ktconfiguration, after scanning a QR code (when invoked without intent data), the app will proceed toPreScanningActiveCaptureActivityactivity for Active Face Capture orPreScanningPassiveCaptureActivityfor Passive Face Capture.
When theQRScanActivityis invoked with an extra, the activity will attempt to read the non-face-encrypted regions of a SensePrint eID QR code and show that data by passing it in an intent and launching theReaderDetailActivity. -
ActiveFaceCaptureActivity
This activity may be invoked with or without intent extras.
When invoked with an extra containing the SensePrint bytes (from theQRScanActivity), the activity will attempt to decrypt the SensePrint bytes and pass the metadata along to thePersonDetailActivity.
When invoked without any extras, the activity will pass the captured image via an intent by launching theGenerateQRActivity. -
PassiveFaceCaptureActivity
This activity works in exactly the same way as theActiveFaceCaptureActivity. The only difference is that it captures a single good image from the session. -
ReaderDetailActivity
This activity gets clear text data (non-face encrypted) in an intent and displays it on the screen for viewing. -
PersonDetailActivity
This activity shows the eID attributes that are passed to it via an intent extra. -
GenerateQRActivity
When invoked from theActiveFaceCaptureActivityorPassiveFaceCaptureActivity, this activity prompts for input of eID attributes such as name, ID etc.
Upon accepting the input, the activity invokes theShowQRActivityto show the generated QR code. -
ShowQRActivity
This activity accepts QR code bytes as an intent extra, and shows a generated QR code containing those bytes on the screen. -
GenerateSettingActivity
The GenerateSettingActivity provides configuration options for the face capture process during sense print generation. It includes the following settings:
-
Face Capture Mode
Can be set to either Active Face Capture Mode or Passive Face Capture Mode.
Passive Face Capture Mode Options
-
Camera Orientation: Allows selection between front or back camera.
-
Liveness Detection: Provides an option to enable or disable liveness detection for sense print generation.
-
-
VerifyingSettingActivity
The VerifyingSettingActivity provides configuration options for the face capture process during the verification stage. The settings include:
-
Face Capture Mode
Can be set to either Active Face Capture Mode or Passive Face Capture Mode.
Passive Face Capture Mode Options
-
Camera Orientation: Allows selection between front or back camera.
-
Liveness Detection: Not configurable in this stage, as the selection is determined during the sense print generation process.
-
-
Setting SDK Mode Activity
The SettingSDKModeActivity provides options to switch between different SDK modes.
-
SDK Mode Selection
Can be switched between Online Mode and Offline Mode.
When Offline Mode is selected, required models will be downloaded from the server and stored in the application's folder.
-
Benefits of Offline Mode
Reduces the overall APK size by not bundling all models within the application.
Ensures efficient storage management by downloading only necessary models.
-
-
Download Models View
- When the user switches to Offline mode for the first time, the app will display a view to download all the required model.
- Note: When you receive the app bundle from us, you will need to provide your own download URL for the models.
- To do this, host only the
fr_n.binmodels on your own server (you can use any hosting provider), and update the URL in the constant variableDownload_URL_FOR_FR_N_BIN_MODEL. This step is necessary for the download feature to work properly.
Additional Notes
The SDK is designed for modularity, allowing full customization of the user interface and integration flows while maintaining core functionality within a closed-source native library.
This document serves as a guide to understand and integrate the Android SDK into your application. Be sure to configure the constants accurately to align with your deployment setup and security requirements.