Permission Denial: startActivity asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL

The user 0 and user -2 you are seeing are framework userIds, not Linux uids. From android.os.UserHandle, you can see that userId 0 is the device owner, USER_OWNER (this is totally different than the Linux uid 0, which is root). userId -1 represents all users (USER_ALL), userId -2 represents the current user (USER_CURRENT), userId -3 represents the current user or self (CURRENT_OR_SELF), and userId -10000 represents the null user (USER_NULL).

As far as the permission INTERACT_ACROSS_USERS_FULL, you can declare it in your manifest file, but you will only be granted it if your app is in the Android system image or signed with the same certificate as another application in the system image that declares the permission. In other words it is a signature or signatureOrSystem permission.


As @juanmf mentioned in a comment, adding the --user 0 option to the command resolved the issue for me. The resulting command would look like this:

am start --user 0 -a android.intent.action.VIEW -n com.android.browser/com.android.browser.BrowserActivity

Tags:

Android