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.).
adbFirst, list all available roles your device supports:
bashadb shell cmd role list-roles
This will show you all possible roles, such as:
android.app.role.BROWSERandroid.app.role.HOMEandroid.app.role.DIALERandroid.app.role.MESSAGINGUse the following command to set a role for a specific app (replace <package-name> and <role>):
bashadb 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:
bashadb shell cmd role set-role com.android.chrome android.app.role.BROWSER
To check if the role was set correctly:
bashadb shell cmd role list-roles-by-package <package-name>
--user flag.