简体   繁体   English

使用 ADB 在 android WEBAPP 上启动

[英]Launching on android WEBAPP with ADB

Is there a method to launch a web app using adb?有没有使用 adb 启动网络应用程序的方法? The web app is created using manifest.json and save on android using chrome browser. Web 应用程序是使用 manifest.json 创建的,并使用 chrome 浏览器保存在 android 上。 I've tried to get the package name of the web application using adb shell pm list packages but nothing seems to match.我尝试使用adb shell pm list packages获取 Web 应用程序的包名,但似乎没有任何匹配。 I want to launch my web app this way adb shell am start -n com.package.name/com.package.name.ActivityName我想以这种方式启动我的网络应用程序adb shell am start -n com.package.name/com.package.name.ActivityName

I've also tried this way adb shell am start -a android.intent.action.VIEW -d "url" .我也试过这种方式adb shell am start -a android.intent.action.VIEW -d "url" This works but it is not what I am looking for.这有效,但这不是我要找的。

Assuming you are coming from Javascript world (as you could have done this by looking at adb logs), this should be what you are looking for假设您来自 Javascript 世界(因为您可以通过查看 adb 日志来完成此操作),这应该是您正在寻找的

 adb shell am start -a com.google.android.apps.chrome.webapps.WebappManager.ACTION_START_WEBAPP -n com.android.chrome/org.chromium.chrome.browser.webapps.WebappLauncherActivity --es "org.chromium.chrome.browser.webapp_url" "{your_url}" --es "org.chromium.chrome.browser.webapp_mac" "{webapp_mac}"

Note that this url has to match the url/url-ending you have mentioned in the start_url that you have mentioned in the manifest.json of yours, else it will just open it as another chrome tab.请注意,此 url 必须与您在您的 manifest.json 中提到的start_url中提到的 url/url-ending 匹配,否则它只会将其作为另一个 chrome 选项卡打开。

Another caveat here is you have to pass web app mac validation check, which is done by the core android class mentioned here - WebappAuthenticator这里的另一个警告是你必须通过 web 应用程序 mac 验证检查,这是由这里提到的核心 android 类完成的 - WebappAuthenticator

Chrome does not keep a store of valid URLs for installed web apps (because it cannot know when any have been uninstalled). Chrome 不会为已安装的网络应用程序保留有效 URL 的存储(因为它无法知道任何已卸载的时间)。 Therefore, upon installation, it tells the Launcher a message authentication code (MAC) along with the URL for the web app, and then Chrome can verify the MAC when starting eg {@link #FullScreenActivity}.因此,在安装时,它会告诉启动器一个消息验证码 (MAC) 以及 Web 应用程序的 URL,然后 Chrome 可以在启动时验证 MAC,例如 {@link #FullScreenActivity}。 Chrome can thus distinguish between legitimate, installed web apps and arbitrary other URLs.因此,Chrome 可以区分合法的、已安装的网络应用程序和任意其他 URL。

I gave it a shot to open one of the webapps I own.我试了一下打开我拥有的一个 web 应用程序。 I gave up after a bit, getting lost in the cryptic algos.过了一会儿,我放弃了,迷失在神秘的算法中。 Maybe you will have some luck with it.也许你会有一些运气。 All the best!!!祝一切顺利!!!

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

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