When I\'m trying to use android \'am\' command to start an activity ,it\'s wrong under 4.2 platform(I tried , it\'s ok under 2.3 version).The code is like this
Permissions are just a line of code that you need to add in the manifest to inform that you accessing those resources and requesting android to allow these resources to use.
1) i just added an example containing permission.
2) In Linux there is root user ,group and others . 0 comes to root and UID cannot be negative its value is between 0 - 999. See this link
1)In linux every user has an id number. 0 and -2 are User IDs (UIDs). 0 is root, -2 is some random user (which may not be a person, it may just be a fake account used for internal reasons).
2)Any book on Linux. Android is just a graphical framework on top of Linux.
3)Yes, just add the permission.
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
I was receiving this error after my Samsung Galaxy Tab Active 2 tablet upgraded to Android 9. After much searching, I found this post that suggested turning developer options off, restarting the tablet, then turning developer options back on. I ended up just turning USB Debugging off, restarting, then turning USB debugging back on, and everything worked fine after that.