我目前正在使用以下方法在 Android 设备的 native 浏览器中打开一个选项卡
adb shell am start -a "android.intent.action.VIEW" -d "http://google.co.uk"
我遇到的问题是每次发送命令时都会打开一个新选项卡。为了解决这个问题,我试图关闭浏览器以尝试重新启动,但是,之前的选项卡被记住了。
adb shell am force-stop com.android.browser
我之前也试过杀人,但是这个好像没用
adb shell am kill com.android.browser
我做了一些快速阅读并找到了选项 create_new_tab
但我相信这是针对 chrome 而不是 native 浏览器的。
adb shell am start -a "android.intent.action.VIEW" -d "http://google.co.uk" --ez create_new_tab false
有谁知道如何使用单个选项卡,如果不存在则打开一个选项卡,如果存在则使用现有选项卡。我正在使用 Windows 命令行。
最佳答案
我能够通过以下命令重用相同的浏览器选项卡:
adb shell am start -a "android.intent.action.VIEW" -d "http://www.google.com" --es "com.android.browser.application_id" "com.package.name"
一些文档可以在这里找到: https://developer.android.com/reference/android/provider/Browser.html#EXTRA_APPLICATION_ID
关于Android ADB 在当前选项卡中打开 URL/关闭以前的选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44803141/