简体   繁体   English

以编程方式安装Android APK

[英]Installing an Android apk programmatically

I am trying to install APKs from our file server, and it needs to be done silently without the user being able to choose whether or not it's installed or accept permission settings/changes. 我正在尝试从文件服务器安装APK,并且它需要以静默方式完成,而用户无法选择是否已安装或接受权限设置/更改。 This is a legit business requirement as we are working with a device vendor to preload our applications into /system/app. 这是一项合法的业务需求,因为我们正在与设备供应商合作将我们的应用程序预加载到/ system / app中。 This is a custom Android tablet device, and as such, our business unit want to ensure we can push app updates (ie force the latest version). 这是一个自定义的Android平板设备,因此,我们的业务部门希望确保我们可以推送应用更新(即强制使用最新版本)。

I understand the usual security restrictions, but there seems to be a mechanism to install applications silently for vendor/manufacture level apps. 我了解通常的安全限制,但似乎有一种机制可以为供应商/制造级应用程序静默安装应用程序。 However the information on how to do this seems very spotty at best. 但是,有关如何执行此操作的信息充其量似乎充其量。

It seems the package installer must be in /system/app and the installer must have the same signing cert key as the app being installed. 软件包安装程序似乎必须在/ system / app中,并且安装程序必须与要安装的应用程序具有相同的签名证书密钥。 That's not a problem, but info on how to implement this feature using this flow is something I have yet to find. 这不是问题,但是我还没有找到有关如何使用此流程实现此功能的信息。

Anyone ever done this before? 有人做过吗?

I'm fairly certain you'll need to ship them a custom Android ROM that allows you to be able to do this (which I doubt their business will enjoy). 我相当确定您需要为他们提供一个自定义的Android ROM,使您能够执行此操作(我怀疑他们的业务会满意)。

The Amazon App Store on a normal device can't install silently in the background like Google Play can. 普通设备上的Amazon App Store不能像Google Play那样在后台静默安装。 Maybe the Kindle Fire can do this (I don't own one), but if it can, its because its running on a custom ROM built by Amazon. 也许Kindle Fire可以做到这一点(我不拥有),但是如果可以的话,这是因为它可以在Amazon构建的自定义ROM上运行。

The best thing you could do is launch an intent that tells brings the user to the app needs to be updated, which brings them to installer activity, which then requires user interaction. 您可能要做的最好的事情是启动一个意图,该意图告诉用户需要更新的应用程序,从而使他们进入安装程序活动,然后需要用户交互。

Not exactly an answer. 不完全是一个答案。 However, we recently faced similar requirement for an android client-server app. 但是,我们最近遇到了对Android客户端-服务器应用程序的类似要求。

Whenever the application contacts server with a request, it sends the current versionCode as well. 每当应用程序与服务器联系请求时,它也会发送当前的versionCode。

PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
//pInfo.versionCode;
//pInfo.versionName;

On server side we check the versionCode and if we have a new version, informs the client and client forces the user to upgrade to the new version. 在服务器端,我们检查versionCode,如果有新版本,则通知客户端,客户端强制用户升级到新版本。 The client app will not work until it is upgraded to the new version. 客户端应用程序必须先升级到新版本,然后才能运行。 But obviously user can choose to not install etc. 但是显然用户可以选择不安装等。

Hope it helps. 希望能帮助到你。

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

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