如何通过亚行获得当前正在运行的活动的更多信息 [英] How to get extras of currently running activity through ADB
问题描述
我对使用ADB有疑问。
I have a question about using ADB.
我知道以下命令:
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 ?
我需要这样做的原因是因为我正在尝试启动apk(是通过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'"
可以正常工作并提出申请。该应用程序有一个开始屏幕(例如我们称为HomeActivity),您必须单击一个按钮并进行一些选择(例如SelectionActivity),然后它将转到另一个屏幕(例如ActionActivity)。我希望能够启动apk并将其直接转到ActionActivity。
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.
如果我尝试使用am start命令启动ActionActivity,应用程序将崩溃。 m假设这是因为它需要SelectionActivity屏幕中的参数。
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.
这就是为什么我试图查看ActionActivity屏幕实际上是什么附加或参数的原因得到,这样我就可以执行以下操作:
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'"
希望我的问题很清楚。
如果我在某个地方犯了一个错误,请纠正我。
Please correct me if I'm making a mistake somewhere.
谢谢!
推荐答案
如果我正确理解,您的目标是以正确的意图启动操作活动,但您不知道应该使用哪种参数信息
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?
dumpsys命令不会转储e您想要的东西,因此只要简单地实现目标,您有2种选择(您应该找到一台可以将自己的固件刻录到其中的设备):
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):
-
修改AMS中的转储方法以打印出更多信息
Modify the dump method in AMS to print out more information
修改ActivityThread类源代码以打印出详细的意图信息
Modify the ActivityThread class source code to print out the detailed intent information
这篇关于如何通过亚行获得当前正在运行的活动的更多信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!