如何通过包名自动安装Play商店应用程序?

3
是否有可能通过在adb shell或其他方式(有或没有root权限)传递软件包名称来批量安装常规的play商店应用程序?
不是要安装APK文件,而是使用play商店功能,根据其软件包(例如com.android.chrome)静默下载和安装应用程序(或带确认)。
例如,当您在https://play.google.com的桌面版中单击应用程序的“安装”按钮时,该应用程序会以静默方式下载并安装到所选设备上,对于桌面浏览器中使用的gmail帐户。 我想象这是由Google云消息平台(FCM / GCM)触发的意图。是否可以通过调用相应的gapps活动来直接在设备上触发相同的功能,并提供软件包名称?
2个回答

2

这只是一种半自动化的方法,但当我尝试在新手机上安装之前使用的所有应用程序时,它确实为我节省了很多时间。

以下是我是如何做到的:

  1. Save the list of package names in a file, for example /sdcard/pkgs.

  2. After entering the shell by typing adb shell, define the following shell function using the following command:

    g() { am start -a android.intent.action.VIEW -d "market://details?id=$1" -p com.android.vending; }
    

    This shell function will open the Google Play info page for a given package. For example, to open the Google Play info page for Chrome, you can use the command g com.android.chrome.

  3. Type the following command to interactively install all the apps in the file /sdcard/pkgs:

    for p in `cat /sdcard/pkgs`; do echo $p; g $p; read; done
    

    This command will open the Google Play info page of all the packages in /sdcard/pkgs one at a time, and will not proceed to the next app unless you press the enter key. At this point, all you have to do is to tap the install button on your phone and then press the enter key on your computer. As long you see the "pending" state you can proceed to the next app. You don't need to wait until the installation to finish.

当然,第三步可以通过模拟触摸事件进行自动化,例如使用input tap x y命令。对我来说,这并不值得花费精力,因为我不想处理所有的异常情况(例如应用程序在谷歌商店上不再可用,或者电话打断了等等)。


0

在终端中使用以下abd命令进行安装: "adb install appname.apk" 安装成功后,您将收到一个成功消息。


原始问题明确指出,它不是关于安装APK文件的问题,而是通过Google Play商店触发设备上的远程安装。 - ccpizza

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接