检查版本,如果版本不同则OTA安装apk
我正在尝试构建这个应用程序,现在已经基本完成了。我正在尝试通过
- 提供 OTA 支持
- 来改进它。为此,请检查版本、下载 apk 并安装它。
一些研究指出我要使用意图,但不是很清楚。
一步一步的程序将不胜感激。
提前致谢。
PS:由于某些要求,我可能不会在市场上发布它。因此,上传到市场的可能性被排除。
I am trying to build this app which is almost complete now. I am trying to improve it by
- Providing OTA support
- In order to do that check the version, download apk and install it.
Some research pointed me to use Intents but was not very clear.
A step-by-step procedure will be much appreciated.
Thanks in advance.
PS: I may not be publishing it in the market because of certain requirements. So uploading to market is ruled out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过使用 ACTION_VIEW 和 apk 文件发送意图来以编程方式安装 APK。这将打开应用程序安装程序,如果清单中的构建版本高于已安装应用程序中的版本,则安装程序将安装它。
请参阅此处了解该部分的类似问题。
您需要定期轮询服务器上的某个文件,该文件可以返回最新版本号,并通过 PackageManager (调用 getPackageInfo() 并检查 PackageInfo.versionCode)。
You can install an APK programatically by sending an intent with ACTION_VIEW with the apk file. This will open the application installer, which will install it if the build version in the manifest is higher than the one in the installed application.
See a similar question here for that part.
You'd need to poll a file on your server somewhere periodically that can return the latest version number, and compare it to the currently installed application version number through PackageManager (call getPackageInfo() and check PackageInfo.versionCode).