1

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?

1
  • 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 Commented Sep 30, 2013 at 8:34

2 Answers 2

4

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

6
  • 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? Commented Sep 30, 2013 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
    Commented Sep 30, 2013 at 11:10
  • understood. thnx again Commented Sep 30, 2013 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
    Commented Dec 6, 2015 at 6:08
  • I got bad component name : --user Commented Dec 14, 2015 at 13:21
-2

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"'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .