简体   繁体   English

在 android studio 中以编程方式将 apk 从本地资产目录安装/卸载到真实设备

[英]Programmatically install/uninstall apk from local asset directory to real device in android studio

For Automation Testing I need to install on Apk programmatically and verify that the app is installed.对于自动化测试,我需要以编程方式在 Apk 上安装并验证是否已安装该应用程序。 and programmatically uninstall it and verify the app is uninstalled from the real device.并以编程方式卸载它并验证该应用程序是否已从真实设备上卸载。 I am not looking for a UI to download and install, without any UI when I run the java file in the android studio it should install/uninstall.我不是在寻找要下载和安装的 UI,当我在 android 工作室中运行 java 文件时没有任何 UI,它应该安装/卸载。 Can anyone tell me how can I achieve this?谁能告诉我如何实现这一目标?

You can likely achieve this by using a combination of PackageInstaller and PackageManager您可以通过组合使用PackageInstallerPackageManager来实现这一点

As mentioned in the documentation for PackageInstaller, you'll need to be either the device owner or the affiliated profile owner, or it will require user intervention to complete installation.如 PackageInstaller 文档中所述,您需要是设备所有者或附属配置文件所有者,否则将需要用户干预才能完成安装。

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

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