从亚行发起YouTube搜索

时间:2018-11-03 07:24:39

标签: android android-intent youtube adb raspbian

我正在尝试从ADB(从树莓派的另一台设备)启动youtube搜索。

所以我想启动youtube应用,然后启动搜索“测试”

我可以使用以下方法启动youtube应用:      壳猴-p com.google.android.youtube.tv -c android.intent.category.LAUNCHER 1

但是我找不到如何启动搜索的方法。 我猜它正在使用intent.action.search ...

正确的代码是什么? 并且您有任何链接解释如何使用adb和intent吗?

我很难找到任何解释

谢谢

1 个答案:

答案 0 :(得分:0)

第一种方法
由于我没有android电视,因此没有youtube电视应用。我将在移动设备中预装的youtube应用的帮助下进行说明。

用于在com.google.android.youtube上打开搜索的Intent是预先安装在android手机上的

  

com.google.android.youtube.action.open.search

您可以在应用的android清单中找到此意图。 请格外注意清单中的android:exported

这是打开应用程序并打开搜索栏的完整命令语法。

adb shell am start -a [intent action name] -n [activity name]

要在任何应用中获取活动名称,请转到该应用并单击该活动,然后运行该

  

adb shell dumpsys窗口窗口| grep -E'mCurrentFocus | mFocusedApp'

这就是我的情况

mCurrentFocus=Window{a4d41d0 u0 com.google.android.youtube/com.google.android.apps.youtube.app.WatchWhileActivity}
mFocusedApp=AppWindowToken{31adc14 token=Token{c0a51f0 ActivityRecord{c314a33 u0 com.google.android.youtube/com.google.android.apps.youtube.app.WatchWhileActivity t283}}}

就我而言,活动是

com.google.android.youtube/com.google.android.apps.youtube.app.WatchWhileActivity

因此打开搜索栏,我将输入

adb shell am start -a com.google.android.youtube.action.open.search -n com.google.android.youtube/com.google.android.apps.youtube.app.WatchWhileActivity

然后键入任何内容,有很多选项,其中之一是通过虚拟键盘发送键,例如

adb shell input text "hello"

要了解更多选项,您可以输入

adb shell input text help


第二种方法
另一种方法是,使用am start打开活动后,单击搜索栏。
首先,您需要通过单击搜索栏并使用capturing its coordinates来了解搜索栏的坐标

 adb shell getevent -l

然后使用

发送触摸
adb shell input tap [x_coordinate] [y_coordinate]



Here是有关adb和intent的文档。 希望这会有所帮助。