On Android how to set an app role with `adb`?
Apr 11, 7:18pm

On Android, you can use adb (Android Debug Bridge) to set an app role (or app association) for certain system-level actions, such as setting an app as the default handler for a specific intent (e.g., default browser, default launcher, etc.).

How to Set an App Role with adb

1. List Available Roles

First, list all available roles your device supports:

bash
adb shell cmd role list-roles

This will show you all possible roles, such as:

  • android.app.role.BROWSER
  • android.app.role.HOME
  • android.app.role.DIALER
  • android.app.role.MESSAGING
  • etc.

2. Set the Role for an App

Use the following command to set a role for a specific app (replace <package-name> and <role>):

bash
adb shell cmd role set-role <package-name> <role> [--user <user-id>]
  • <package-name>: The package name of the app (e.g., com.android.chrome).
  • <role>: The role you want to assign (e.g., android.app.role.BROWSER).
  • --user <user-id> (optional): Specify the user ID if you want to set the role for a specific user profile.

Example:
To set Chrome as the default browser:

bash
adb shell cmd role set-role com.android.chrome android.app.role.BROWSER

3. Verify the Role

To check if the role was set correctly:

bash
adb shell cmd role list-roles-by-package <package-name>

Notes

  • Requires ADB Debugging: Your device must have USB debugging enabled in Developer Options.
  • Root Access: Some roles may require root access.
  • User Profiles: If you have multiple user profiles, specify the --user flag.
  • Android Version: The exact command may vary slightly depending on your Android version.

Apr 11, 7:18pm

This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.