Android: JB 4.2.2

I am trying to launch Android apps from the terminal emulator using the am command. When I tried the phone's terminal emulator application, it gave me an error:-

java.lang.SecurityException: Permission Denial: startActivity asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL
    at android.os.Parcel.readException(Parcel.java:1425)
    at android.os.Parcel.readException(Parcel.java:1379)
    at android.app.ActivityManagerProxy.startActivityAsUser(ActivityManagerNative.java:1906)
    at com.android.commands.am.Am.runStart(Am.java:494)
    at com.android.commands.am.Am.run(Am.java:109)
    at com.android.commands.am.Am.main(Am.java:82)
    at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
    at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:235)
    at dalvik.system.NativeStart.main(Native Method)

If I go into root mode, then the am command works. Any idea how to get am to launch browser without doing an su in the terminal emulator?

  • Hi, actually when i use "am" without root the err msg is: Permissio denied, app requested to run as user 2 but calling from user 0. I ggogled this, google results have the exact same err msg – Kartikeya Shukla Sep 30 '13 at 8:34

You just need to add the --user 0 option to your am command.

  • Hello, your solution worked perfectly. thank you very much, u see until now i was wooried that all my android apps were being launched by "am" as root. I hope that is not the case right now? – Kartikeya Shukla Sep 30 '13 at 11:01
  • 1
    No, that's not the case. The "user" in the command-line refers to Jelly Bean's user profiles, not to Unix user IDs. When you're using a terminal session, you need to specify which user profile the app should be running in. – Dan Hulme Sep 30 '13 at 11:10
  • understood. thnx again – Kartikeya Shukla Sep 30 '13 at 11:11
  • Very interesting comment. I until now assumed that the user in terminal emulator doesn't have sufficient privileges to use am command. – Firelord Dec 6 '15 at 6:08
  • I got bad component name : --user – Milad Faridnia Dec 14 '15 at 13:21

I was trying to start service from terminal and i got similar output. In my case i just added qoutation marks and that helped.

su -c 'am startservice -n "com.example.app/.YourSe-rvice" -e "extra' "value"'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.