10

I have a question about using ADB.

I know that this command:

adb shell dumpsys activity

can show me all the activities that are currently running on the device.

But I notice that sometimes, the intents appear like this:

Intent { ...some_intent/activity_name.... (has extras) }

I know that extras mean that the activity has been started with some sort of parameters passed to it (I may be wrong here, please correct me if I am).

So my question is, how can I get the extras of the intent/activity through ADB ?

The reason I need this is because I'm trying to launch an apk (that is installed on the phone) through ADB command, something like:

adb shell "su -c 'am start -n com.package.name/.ActivityName'"

That works and bring up the application. The application has a start screen (say we call it HomeActivity) and you have to click a button and make some selections (say SelectionActivity) and it will go to another screen (say ActionActivity). I want to be able to launch the apk and make it go straight to ActionActivity.

The application will crash if I try to launch the ActionActivity with am start command, I'm assuming this is because it requires parameters from the SelectionActivity screen.

This is why I'm trying to see what are the "extras" or parameters that the ActionActivity screen actually gets, so that I can do something like:

adb shell "su -c 'am start -n com.package.name/.ActionActivity -e param1 val1 -e param2 val2'"

Hope my question is clear.

Please correct me if I'm making a mistake somewhere.

Thanks in advance!

JJackJi
  • 195
  • 1
  • 3
  • 10
  • See if this helps: [How can I deliver parameters to a test function, that launched using adb shell am Instrumentation command](http://stackoverflow.com/a/3229077/2558882). – Vikram Aug 30 '13 at 00:15
  • How do you know it's only extras missing? The first Activity could do something else. BTW, you don't usually need `su` to run `am`. – Diego Torres Milano Aug 30 '13 at 03:32
  • 1
    Did you ever figure out an answer to this? I'm trying to do the exact same thing. – Andi Jay Apr 10 '14 at 18:17
  • Hello @AndiJay. Sorry for the late reply. I actually never figured this out. As Robin (below) suggested, installing custom firmware seems to be the only way to go. – JJackJi Jul 07 '14 at 03:30
  • Eight years later, I have the same use case and still cannot find the extras parameters – a7md0 Sep 26 '21 at 10:32

1 Answers1

2

If I am understanding correctly, your target is to start the 'action' activity with correct intent but you don't know what kind of parameter information should be included, right?

The dumpsys command won't dump everything you want, so to simply achieve your target, you have 2 options (you should find one device which you can burn your own firmware into it):

  1. Modify the dump method in AMS to print out more information

  2. Modify the ActivityThread class source code to print out the detailed intent information

Robin
  • 10,052
  • 6
  • 31
  • 52
  • Hi Robin, Thanks for the answer. Unfortunately, I cannot modify the ActivityThread class source code as the apk is not mine, so there is no way I can modify the source code to put anything. – JJackJi Aug 30 '13 at 16:58
  • Hi Robin, Thanks for the answer. Unfortunately, I cannot modify the ActivityThread class source code as the apk is not mine, so there is no way I can modify the source code to print anything extra. As for modifying the dumpsys method, I'm afraid that is not an option for me. My project requires that I use the firmware that currently resides on the phone. Are there no built-in android adb commands to achieve this ? Thanks ! – JJackJi Aug 30 '13 at 22:31
  • I mean, you just want to get the information. So you can use a customized firmware to get the information you want. With a customized firmware you can either modify dumpsys or activity thread source code. They are both framework source codes. This is just an approach for achieve your target. – Robin Sep 01 '13 at 14:04