以编程方式更新 Android 应用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24393950/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 08:05:11  来源:igfitidea点击:

Android update app programmatically

android

提问by Ajay

I have an app, but I want to update it, I read some post of "stackoverflow" (update application programmatically)

我有一个应用程序,但我想更新它,我阅读了一些“stackoverflow”的帖子(以编程方式更新应用程序)

Android programmatically update application when a new version is available

update apk programmatically (without root)

当新版本可用时,Android 以编程方式更新应用程序

以编程方式更新 apk(无需 root)

but none convince me.

但没有人说服我。

I would like information on how to update an app.

我想了解有关如何更新应用程序的信息。

Right now my app is not uploaded on google play, I have it in apk.

现在我的应用程序没有上传到 google play,我有它在 apk 中。

I would upgrade using a button [update click here], and that she is going to take charge "http:www.site/myapk.apk" and to update.

我会使用按钮升级[更新点击这里],她将负责“http:www.site/myapk.apk”并进行更新。

Why say the apk? because every week I will update my app a bit.

为什么说是apk?因为每周我都会更新我的应用程序。

And if they have to always download the apk, it is very frustrating.

如果他们必须总是下载 apk,那就太令人沮丧了。

There an easy and clean way (with code)?

有一种简单而干净的方法(带代码)?

回答by Ajay

please visit this link you may get some idea LINK

请访问此链接,您可能会有所了解LINK

It follows these steps ::

它遵循以下步骤::

1 Create a Web Service which your app can poll whenever the app launches or based on some time limit that can check if there is new version out there.

  1. This Web service should return the lastest Version of the apk file that is hosted on the Server along with the URI of the application file that has the new version.

  2. When your app gets the response from the Web Service, it will parse the JSON and check your app version to the lastest version that is available on the server.

  3. If your app version is lower than the latest version it will prompt the user to start the download process. The download of the new app is handled by the Download Manager.

  4. The download manager will notify your app using Broadcast receiver when the download is complete.

  5. After completion of the latest version of the application file the you can start the activity to install/update that file.

1 创建一个 Web 服务,您的应用程序可以在应用程序启动时轮询该服务,或者基于可以检查是否有新版本的时间限制。

  1. 此 Web 服务应返回托管在服务器上的 apk 文件的最新版本以及具有新版本的应用程序文件的 URI。

  2. 当您的应用从 Web 服务获得响应时,它会解析 JSON 并将您的应用版本检查为服务器上可用的最新版本。

  3. 如果您的应用程序版本低于最新版本,它会提示用户开始下载过程。新应用程序的下载由下载管理器处理。

  4. 下载完成后,下载管理器将使用广播接收器通知您的应用。

  5. 完成最新版本的应用程序文件后,您可以开始安装/更新该文件的活动。

回答by Amin Pinjari

Try this option

试试这个选项

Add google library to update from the application

添加谷歌库以从应用程序更新

  dependencies {
implementation 'com.google.android.play:core:1.5.0'
...}

refer doc from below link

从下面的链接参考文档

https://developer.android.com/guide/app-bundle/in-app-updates#update_readiness

https://developer.android.com/guide/app-bundle/in-app-updates#update_readiness