How to get extras of currently running activity th

2019-03-28 03:02发布

问题:

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!

回答1:

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