简体   繁体   English

Android:以编程方式更新apk文件

[英]Android: Updating an apk file programatically

I want to update an apk file already installed in the device programmatically to a new version from a url. 我想通过网址以编程方式将设备中已经安装的apk文件更新为新版本。 Is there any way to do this other than installing the file again using application/vnd.android.package-archive (Since I'd prefer to do this silently without user actions) 除了使用application / vnd.android.package-archive再次安装文件之外,还有什么方法可以做到这一点(因为我宁愿在没有用户操作的情况下静默地执行此操作)

Not unless you have system privileges. 除非您具有系统特权,否则不可以。 If that were possible, any app would be able to install anything on your device (including malware). 如果可能的话,任何应用程序都可以在您的设备上安装任何东西(包括恶意软件)。

save your current version and url in remote db.and when application starts in device check application version stored in db and installed app version is same or not. 将当前版本和url保存在远程数据库中。当应用程序在设备中启动时,检查存储在数据库中的应用程序版本与安装的应用程序版本是否相同。 if different then download file from url.if not then run current version. 如果不同,则从url下载文件。如果没有,则运行当前版本。

but you have to do these these things manually in code. 但是您必须在代码中手动执行这些操作。

and for this you will need internet connection in device also. 为此,您还需要在设备中连接互联网。

I have done the same. 我也一样 I have my new apk in the FTP server and a version number of the new APk. 我在FTP服务器中有新的APK,还有新的APk的版本号。 I am comparing the version numbers and downloading the APK and installing it. 我正在比较版本号并下载并安装APK。 but before that I am checking for the checksum of the downloaded apk with the checksum in the FTP server to make sure that the APK is downloaded properly. 但在此之前,我要在FTP服务器中检查已下载apk的校验和以及校验和,以确保正确下载了APK。

Automatic installation without the users consent, i don't think it is possible. 未经用户同意自动安装,我认为这是不可能的。 Let me know if you have found a solution for that. 让我知道您是否找到了解决方案。

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

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