Switch Phones, Skip the Hassle: Meet Android’s Restore Credentials

Switching to a new phone is always exciting, but re-entering login details for all your apps? Not so much. It’s a hassle that frustrates users and, often, makes them abandon apps entirely. To solve this, Android is rolling out a new feature called Restore Credentials, part of its Credential Manager API.

This feature makes setting up apps on a new phone smooth and effortless. Users stay logged in, and apps re-engage them immediately—no need to remember or retype credentials. Here’s everything you need to know about how it works and why it’s a win for users and developers alike.


What is Restore Credentials?

Restore Credentials is a new tool that helps apps restore user accounts automatically when users move to a new device. It works during the setup process:

  1. Users restore their apps and data (from the cloud or locally).
  2. Apps fetch a special restore key saved on the old device and log the user in automatically.

No additional steps or credentials are required from the user. It’s as if they never left their old phone!


Why It’s Great for Users and Developers

  • For Users:
    • Hassle-Free Setup: Switch phones without worrying about logins.
    • Instant Access: Notifications and account data are ready to go as soon as apps are restored.
  • For Developers:
    • No Extra Effort: Restore Credentials works with Android’s existing backup system.
    • Seamless Integration: Uses the same server-side setup as passkeys (FIDO2 compatible).
    • Better Retention: Reduce churn by keeping users connected effortlessly.

How Restore Credentials Works

On the Old Phone:

  • The app creates a restore key when the user logs in. This key is stored locally and, if allowed, backed up to the cloud.

On the New Phone:

  • During device setup, users can restore data via the cloud or locally.
  • The restore key is transferred along with the app data.
  • Once available, the app uses this key to log the user in automatically.

Apps using Android’s BackupAgent can even log users in silently, so they never need to touch a button.


How to Add Restore Credentials to Your App

Using the Jetpack Credential Manager makes adding this feature easy. Here’s the basic process:

  1. Create a Restore Credential: Generate a restore key when users log in to your app.
  2. Retrieve the Credential: When a user restores the app on a new device, fetch the restore key and log them in.
  3. Clear the Credential: If users log out, delete the restore key to avoid auto-logins.

Here’s how the code looks:

// Add Credential Manager dependency
implementation("androidx.credentials:credentials:1.5.0-beta01")
// Create a Restore Credential
val createRequest = CreateRestoreCredentialRequest(registrationJson, true)
val response = CredentialManager.create(context).createCredential(context, createRequest)

// Retrieve the Restore Credential
val getRequest = GetCredentialRequest(listOf(GetRestoreCredentialOption(authenticationJson)))
val response = CredentialManager.create(context).getCredential(context, getRequest)

// Clear the Credential
val clearRequest = ClearCredentialStateRequest(1)
CredentialManager.create(context).clearCredentialState(clearRequest)


Why This Matters

Restore Credentials simplifies life for users and developers alike. Users can seamlessly switch devices without frustration, and developers can reduce app abandonment while ensuring secure, automatic logins.

Want to take your app’s user experience to the next level? Start exploring Restore Credentials with the Jetpack Credential Manager today.

It’s a small step for your app, but a giant leap for user satisfaction!

Leave a Reply

Your email address will not be published. Required fields are marked *