Overview
In this quickstart, you’ll add Fingerprint to a new Android Studio project and identify the user’s device. The example use case we’ll use for this quickstart is stopping new account fraud, where attackers create multiple fake accounts to abuse promotions, exploit systems, or evade bans. However, the steps you’ll follow apply to most use cases. By identifying the device behind each sign-up attempt, login, or transaction, you can flag and block suspicious users early. This guide focuses on the front-end mobile integration. You’ll install the Fingerprint Android SDK and initialize the client to generate a request ID to send to your back end for analysis. To see how to implement fraud prevention with this ID, continue to one of our back-end quickstarts after completing this quickstart.Estimated time: < 10 minutes
Prerequisites
Before you begin, make sure you have the following:- Android Studio installed (latest stable version recommended)
- Basic knowledge of Kotlin and Android development
This quickstart only covers the front-end setup. You’ll need a back-end
server to receive and process the device identification event to enable fraud detection. Check out one of our back-end
quickstarts after completing this quickstart.
1. Create a Fingerprint account and get your API key
- Sign up for a free Fingerprint trial if you don’t already have an account.
- After signing in, go to the API keys page in the dashboard.
- Copy your public API key; you’ll need it to initialize the Fingerprint client agent.
2. Set up your project
To get started, create a new Android Studio project. If you already have a project you want to use, you can skip to the next section.- Open Android Studio and choose New Project.
- Select Empty Activity, then click Next.
- Name your project (for example, “Fingerprint Quickstart”).
- Keep the default settings (as of this writing, that’s API 24: Android 7.0 (Nougat) as the minimum SDK and Kotlin as the language).
- Click Finish.
3. Install the Fingerprint SDK
To integrate Fingerprint into your Android app, first add the SDK to your project.Add the Fingerprint Maven repository
- In Android Studio, make sure you’re in Android view (top-left dropdown in the Project pane).
- Expand the Gradle Scripts section and open
settings.gradle.kts. - Find the
dependencyResolutionManagementblock and update the repositories section to include the Fingerprint Maven repository:
settings.gradle.kts
Add the SDK dependency
- In the same Gradle Scripts section, open
build.gradle.kts (Module: app). - Inside the
dependenciesblock, add:
build.gradle.kts
Sync your project
After editing the files, sync your project by either:- Clicking Sync Now in the banner that appears.
- Or going to File > Sync Project with Gradle Files.
4. Initialize the SDK
Now that the SDK is installed, you can import and initialize it in your app.- In Android view, open
MainActivity.kt(in app > kotlin+java > [your.package.name]) and add the following imports:
MainActivity.kt
- Additionally, add these imports you’ll need for some basic UI:
MainActivity.kt
- Next, initialize the Fingerprint client before
setContentin youronCreatefunction:
MainActivity.kt
- Replace
<your-public-api-key>with your actual public API key from the Fingerprint dashboard.
5. Trigger visitor identification
Now that the Fingerprint client is initialized, you can identify the visitor only when needed. In this case, that’s when the user taps a Create Account button. When making the visitor identification request, you will receive thevisitorId as well as a requestId. Instead of using the visitorId returned directly on the front end (which could be tampered with), you’ll send the requestId to your back end. This ID is unique to each identification event. Your server can then use the Fingerprint Events API and retrieve the complete identification data, including the trusted visitor ID and other actionable insights like whether they are using a VPN or are a bot.
Add a basic sign-up UI with Compose
- Create a new composable function for the account creation screen. It will display a simple form with username and password fields, along with a Create Account button:
MainActivity.kt
- Replace the existing call to
Greetingin youronCreatefunction with theCreateAccountScreencomposable and pass in a placeholder for the submit function. Be sure to apply the providedinnerPaddingso the content respects system UI insets:
MainActivity.kt
- Now replace the placeholder
onSubmitfunction with a call to Fingerprint’sgetVisitorIdmethod. This will capture the device’s details and return arequestId, which you can then send to your back end for your fraud detection logic:
MainActivity.kt
6. Run the app
-
Run the app on an emulator or physical device.
To learn how to set up Android Studio to run an emulator or connect a physical Android device, see the official Android Studio setup guide.
- Type in a username and password and click the Create Account button.
-
Open Logcat (View > Tool Windows > Logcat) and filter by the Fingerprint tag (
tag:Fingerprint) to find your log message:
Output
Next steps
To use the identification data for fraud detection (like blocking repeat fake account creation attempts), you’ll need to send therequestId to your back end. From there, your server can call the Fingerprint Events API to retrieve the full visitor information and make decisions.
Check out these related resources: