Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get extras of currently running activity through ADB

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!

like image 854
JJackJi Avatar asked Aug 29 '13 23:08

JJackJi


People also ask

How do I find my current activity name adb?

In Eclipse with Android device attached go to Window menu > Show View > Other ... use filter text "Windows" to pull up Android > Windows ... show this. The top item in the list is the current activity.

What cool things can I do with adb?

ADB, Android Debug Bridge, is a command-line utility included with Google's Android SDK. ADB can control your device over USB from a computer, copy files back and forth, install and uninstall apps, run shell commands, and more.


1 Answers

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

like image 51
Robin Avatar answered Oct 01 '22 23:10

Robin