简体   繁体   English

通过adb shell启动SL4A应用程序

[英]Launch SL4A Application via adb shell

I have tried variations on starting activities including this link and the Google prescribed way of starting a background script in SL4A. 我尝试过各种各样的开始活动,包括此链接Google规定的在SL4A中启动后台脚本的方法。

However I only need to know the command for opening the actual SL4A application through the adb shell. 但是我只需要知道通过adb shell打开实际SL4A应用程序的命令。 It is confusing which activity in that mass of code should be launched first. 令人困惑的是,应首先启动大量代码中的哪些活动。 Also the command: 还有命令:

adb shell am start...

does not have the best documentation. 没有最好的文档。 Could someone please just give me the command to launch SL4A from adb? 有人可以请给我从adb启动SL4A的命令吗?

Thank you so much 非常感谢

There is no simple command for running SL4A apps. 没有简单的命令来运行SL4A应用程序。 SL4A as an activity has no command line interface. SL4A作为活动没有命令行界面。

The one you'll want to look at is this: 你要看的是这个:

$ am start -a com.googlecode.android_scripting.action.LAUNCH_FOREGROUND_SCRIPT -n com.googlecode.android_scripting/.activity.ScriptingLayerServiceLauncher -e com.googlecode.android_scripting.extra.SCRIPT_PATH /sdcard/sl4a/scripts/test.py

What this does is issue an Android intent to SL4A to run a script at the specified path. 这样做是向SL4A发出Android意图以在指定路径上运行脚本。 This path doesn't need to be in the /sdcard/sl4a/scripts directory. 此路径不需要位于/ sdcard / sl4a / scripts目录中。

This is of course a pain to type out at the command line, especially on the device itself. 在命令行输入当然是一种痛苦,特别是在设备本身上。 There's nothing stopping you wrapping it up in a shell script. 没有什么可以阻止你将它包装在shell脚本中。 A suggested example for this is available here 这里提供一个建议的示例

So the goal was to be able to start the application from adb as if you were physically pushing the icon on your home screen. 因此,我们的目标是能够从adb启动应用程序,就像您在主屏幕上按下图标一样。 To do this I looked at the logcat data and found out that the first activity that was being launched was ScriptManager so therefore to start the application, I needed: 为此,我查看了logcat数据,发现正在启动的第一个活动是ScriptManager,因此启动应用程序,我需要:

adb shell am start -n com.googlecode.android_scripting/.activity.ScriptManager

or in a generic case: 或者在一般情况下:

adb shell am start -n <package>/<activity>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM