- Include Android SDK in your mobile apps.
- Get a
visitorId. - Read the SDK response.
- Enable location data collection (optional; to start getting additional location-based proximity data).
- Configure the SDK as per your needs.
- Specify additional metadata in your identification request.
- Handle errors.
Prerequisites
Sign up for an account with Fingerprint to get your API key.Including the SDK in your app
- Add the repositories to your Project Settings file. Depending on your build configuration language, this file can either be
settings.gradle.ktsorsettings.gradle.
build.gradle.kts or build.gradle.
- Add the dependencies to your module-level build file. Depending on your build configuration language, this file can either be
build.gradle.ktsorbuild.gradle.
- Perform a Gradle sync to update all the dependencies.
Getting a visitorId
To get a visitorId, you need the public API key that you obtained when signing up for an account with Fingerprint. You can find this API key in the Dashboard > API Keys.
Here is an example that shows you how to get a visitorId:
Specifying a custom timeout
Default timeout value:null
The identification requests made from an Android SDK do not have a default timeout.
You can use timeoutMillis to provide a custom timeout value of your choice. If the getVisitorId() call does not complete within the specified timeout, you will receive a ClientTimeout error.
Here is an example that shows you how to specify a custom timeout:
Using Location Data for Proximity Detection
This is optional. Enable this only if you want to include the additional location-based proximity detection signal in your response.
allowUseOfLocationData and declaring the corresponding location permissions.
Location permissions
Declaring permissions
To calculate Proximity ID and related data (confidence score, precision radius), Fingerpint needs the following location permissions in the manifest:XML
Asking for permissions
Your app is responsible for asking for permissions. Refer to Android documentation or refer to the Fingerprint demo app if you need to implement this flow. If you already have this process set up, skip to the next section.Enabling location collection
Fingerprint can only collect location data ifallowUseOfLocationData is set to true.
Optionally, you can control the timeout by setting locationTimeoutMillis to the desired value. Note that the value is 5 seconds by default.
Timeout Recommendation:
Because location accuracy and performance can vary based on user settings, device models, and use cases, we do not enforce a fixed default timeout.
We recommend that you explicitly configure a timeout value that aligns with the app’s user experience and performance expectations.
Reading the response
The functionFingerprintJS.getVisitorId() returns the response in a FingerprintJSProResponse object. This object has the following fields, some of which can be empty/invalid when Sealed Client Results is enabled for your account.
| Field | Sealed Client Results is disabled | Sealed Client Results is enabled |
|---|---|---|
requestId | String. An identifier that uniquely identifies this particular request to FingerprintJS.getVisitorID(). | String. An identifier that uniquely identifies this particular request to FingerprintJS.getVisitorID(). |
visitorId | String. An identifier that uniquely identifies the device. | N/A |
confidenceScore | ConfidenceScore. A score that indicates the probability of this device being accurately identified. The value ranges from 0 to 1. | N/A |
sealedResult | null | String?. An encrypted, binary, Base64-encoded String that contains the same response as you would receive with an /events API request |
Configuring the SDK
Using the Configuration object, it is possible to configure the SDK as per your requirements. As of now, the following options are supported:region
Type: Region.
Default value: Region.US
This option allows you to specify a region where you want your data to be stored and processed. This region must be the same as the one you specified when registering your app with Fingerprint. See region for more information.
endpointUrl
Type: String
Default value: Region.US.getEndpointUrl()
This option allows you to specify a custom endpoint, particularly when you have set up either a custom sub-domain or a proxy integration.
fallbackEndpointUrls
Type: List<String>
Default value: emptyList()
This option allows you to specify alternate, fallback endpoints to redirect failed requests.
extendedResponseFormat
Type: Boolean
Default value: false
When set to true, in addition to those fields returned by default, the FingerprintJSProResponse object will also contain the following fields:
visitorFound- Boolean. Indicates if this device has already been encountered by your app.ipAddress- String. The IPv4 address of the device.ipLocation- IPLocation. [This field is deprecated and will not return a result for applications created after January 23rd, 2024. See IP Geolocation for a replacement available in our Smart Signals product.] Indicates the location as deduced from the IP address.osName- String. Indicates the name of the underlying operating system.osVersion- String. Indicates the version of the underlying operating system of the device.firstSeenAt,lastSeenAt- Timestamp. See Visitor Footprint Timestamps.
allowUseOfLocationData
Type: Boolean
Default value: false
This option allows you to enable the location data collection needed to calculate the location-based proximity detection signal.
locationTimeoutMillis
Type: Long
Default value: 5_000L (5 seconds)
This option allows you to configure the maximum timeout for location collection (controlled by allowUseOfLocationData).
Specifying linkedID and tag
Like the JS Agent, the Android SDK also supports providing custom metadata with your identification request. To learn more about this capability, please visit Linking and tagging information.
Here is an example that shows you how to associate your identification request with an account ID and additional metadata:
linkedId and tag on the server.
Handling errors
The SDK provides an Error class that helps you identify the reasons behind an unsuccessful identification request. Here is an example that shows you how to handle errors in your app:Data Classes
ConfidenceScore
Kotlin
Configuration
Kotlin
Error
It’s a sealed class, which can be one of:- ApiKeyRequired
- ApiKeyNotFound
- ApiKeyExpired
- RequestCannotBeParsed
- Failed
- RequestTimeout
- TooManyRequest
- OriginNotAvailable
- PackageNotAuthorized
- HeaderRestricted
- NotAvailableForCrawlBots
- NotAvailableWithoutUA
- WrongRegion
- SubscriptionNotActive
- UnsupportedVersion
- InstallationMethodRestricted
- ResponseCannotBeParsed
- InvalidProxyIntegrationHeaders
- InvalidProxyIntegrationSecret
- NetworkError
- UnknownError
- ClientTimeout
- ProxyIntegrationSecretEnvironmentMismatch
Kotlin
IPLocation
Kotlin
Region
Kotlin
Timestamp
Kotlin