有没有办法在Android上自动更新应用程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3057771/
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
Is there a way to automatically update application on Android?
提问by Levara
I'm developing an application that will most likely be preinstalled on devices. It will be also available on Google Play. Is there a way to update those instances that are not downloaded through Google Play, since Google Play won't notify users about an update.
我正在开发一个很可能会预装在设备上的应用程序。它也将在 Google Play 上提供。有没有办法更新那些不是通过 Google Play 下载的实例,因为 Google Play 不会通知用户更新。
I was thinking about, as suggested here, trying to contact my site periodically, and when update is available, download it.
我正在考虑,按照此处的建议,尝试定期联系我的网站,并在有可用更新时下载。
Is there a way to do this update automatically, or even silently, so that user doesn't have to do anything (like running the package manually). Or, when my site shows update is available, to offer users an update through Google Play, even though it's not installed through Market (EDIT: This Google play option would be preferable, because than users wouldn't have to check "allow install of non-Market sources".)
有没有办法自动或什至静默执行此更新,以便用户无需执行任何操作(例如手动运行包)。或者,当我的网站显示更新可用时,通过 Google Play 为用户提供更新,即使它不是通过 Market 安装的(编辑:此 Google Play 选项会更可取,因为用户不必检查“允许安装非市场来源”。)
回答by Jorgesys
i had the same issue, now i check at the start of my app if theres a new version in my configuration xml.
我有同样的问题,现在我在我的应用程序开始时检查我的配置 xml 中是否有新版本。
I compare the actual version with the tag "< app_version >1.1< /app_version >" of my configuration.xml if its lower i ask with a custom AlertDialog if the user proceed with the upgrade
我将实际版本与我的 configuration.xml 的标记“< app_version >1.1< /app_version >”进行比较,如果它较低,如果用户继续升级,我会使用自定义 AlertDialog 询问
Intent intent = new Intent(Intent.ACTION_VIEW ,Uri.parse(myapk_link));
startActivity(intent);
after the download the user has to run the package manually.
下载后,用户必须手动运行包。
if you choose the update from the Android market use:
如果您从 Android 市场选择更新,请使用:
Intent intent = new Intent(Intent.ACTION_VIEW ,Uri.parse("market://details?id=com.package.name"));
startActivity(intent);
com.package.name
must be the "package" of your app
com.package.name
必须是您的应用程序的“包”
or
或者
Intent intent = new Intent(Intent.ACTION_VIEW ,Uri.parse("market://search?q=" + APP_NAME));
startActivity(intent);
回答by Levara
Just found a way that works.Fire an Intent for a Market that searches for my application.
刚刚找到了一种有效的方法。为搜索我的应用程序的市场触发 Intent。
Tested with OpenIntent Newsreader because for it was easy to find an older version .apk. Market finds an application, and when user clicks install, replaces older version with the one from the Market. I think that is much easier solution for a user than downloading manually .apk and running it.
使用 OpenIntent Newsreader 进行测试,因为很容易找到旧版本的 .apk。Market 找到一个应用程序,当用户单击安装时,将旧版本替换为 Market 中的应用程序。我认为对于用户来说,这比手动下载 .apk 并运行它更容易解决。
Intent intent = new Intent(Intent.ACTION_VIEW ,Uri.parse("market://search?q=" + APPLICATION_NAME));
startActivity(intent);
回答by Briareos386
Is there a way to update those instances that are not downloaded through Google Play, since Google Play won't notify users about an update.
有没有办法更新那些不是通过 Google Play 下载的实例,因为 Google Play 不会通知用户更新。
Old question, new answer:
老问题,新答案:
After digging on exact the same question (pre-installed app on device, how can I provide a update through Google-Play) I found this information on support.google.com*:
在挖掘了完全相同的问题(设备上预装的应用程序,如何通过 Google-Play 提供更新)之后,我在support.google.com*上找到了以下信息:
Google Play can manage updates to preloaded applications, provided the following conditions are met:
- The preloaded app needs to be in the system partition
- The preloaded app needs to be free
- The preloaded app needs to be signed with the same signature as the app published in Google Play
- The Package Name of the preloaded and updated app needs to be the same
- The Version Code of the updated app needs to be greater than that of the preloaded app
如果满足以下条件,Google Play 可以管理预加载应用程序的更新:
- 预加载的应用程序需要在系统分区中
- 预加载的应用程序需要是免费的
- 预加载的应用程序需要使用与 Google Play 中发布的应用程序相同的签名进行签名
- 预加载和更新的应用程序的包名称需要相同
- 更新应用的版本号需要大于预加载应用的版本号
* as of 2015-04-13
* 截至 2015-04-13
回答by CommonsWare
I'm developing an application that will most likely be preinstalled on devices.
我正在开发一个很可能会预装在设备上的应用程序。
Then you need to be talking to the device manufacturers and asking them your questions. Nobody else will be able to tell you what is and is not possible, given their device and the carrier(s) that will distribute it. The answers will depend heavily on how they create their firmware, whether your application will be part of the firmware or "installed" as a normal app, what their arrangement with the carrier is vis a visfirmware updates, etc. You may not even get a vote in the matter.
然后您需要与设备制造商交谈并向他们询问您的问题。考虑到他们的设备和分发设备的运营商,没有其他人能够告诉您什么是可能的,什么是不可能的。这些问题的答案将在很大程度上取决于它们如何创建自己的固件,应用程序是否会在固件或“安装”作为一个正常的应用程序,什么他们与承运人安排的一部分相一相的固件更新,等你甚至可能不会得到对此事进行投票。
回答by Amin Pinjari
Here is the option for latest version update
这是最新版本更新的选项
https://developer.android.com/guide/app-bundle/in-app-updates#update_readiness
https://developer.android.com/guide/app-bundle/in-app-updates#update_readiness
try this google library to update from the application
试试这个谷歌库从应用程序更新
dependencies {
implementation 'com.google.android.play:core:1.5.0'
...}
I hope this will help anyone
我希望这会帮助任何人
回答by hobbs
If whoever bundled the app on the device does a proper job of it, then the app will still have a market link (even as a system app) and Market will prompt the user to upgrade it if a new version is available. After all, that's exactly what happens with an app like GMail that's pre-installed on phones.
如果在设备上捆绑应用程序的人做了适当的工作,那么该应用程序仍将具有市场链接(即使作为系统应用程序),如果有新版本可用,市场将提示用户升级它。毕竟,这正是像 GMail 这样预装在手机上的应用程序发生的情况。
回答by Christopher Orr
You cannot install or upgrade a package automatically. Only the Android Market is capable of doing this (i.e. it silently updates itself).
您无法自动安装或升级软件包。只有 Android Market 能够做到这一点(即它会默默地自我更新)。
You can certainly download a package and fire the Intent
to install it, but the user will have to have the "Allow non-Market apps" options enabled, and they'll still have to manually approve the install/upgrade.
你当然可以下载一个包并启动它Intent
来安装它,但用户必须启用“允许非市场应用程序”选项,他们仍然必须手动批准安装/升级。
One place to possibly investigate is how Google Maps does it. This is generally pre-installed, but always appears to be shown as an update in the Android Market app, I believe. Whether there's a special flag in the packages.xml
or manifest, I don't know.
一个可能需要调查的地方是谷歌地图是如何做到的。这通常是预先安装的,但我相信它总是在 Android Market 应用程序中显示为更新。packages.xml
我不知道在或清单中是否有特殊标志。
回答by CelinHC
There is a nice service that helps your app keep itself updated. Take a look at https://www.pushlink.com
有一项不错的服务可以帮助您的应用程序保持更新。看看https://www.pushlink.com
In this product there is a NINJA mode that allows to perform updates without user interaction.
在该产品中有一个 NINJA 模式,允许在没有用户交互的情况下执行更新。
For other "modes", enabling "Install non-market app" is still needed. If it not enabled, the installation process is going to ask for it and redirect the user to the Application Settings, and after that, the user can install the app.
对于其他“模式”,仍然需要启用“安装非市场应用程序”。如果未启用,安装过程将要求它并将用户重定向到应用程序设置,然后用户可以安装应用程序。
回答by Christine
It's possible to fully automatically update an app, if you can sign an app as a system app. We wrote an app for specific hardware, we created an update app that the manufacturer signed for us. The update app runs on device startup, checks current version of the app and the new version, and installs the new version if necessary.
如果您可以将应用程序签名为系统应用程序,则可以完全自动更新应用程序。我们为特定硬件编写了一个应用程序,我们创建了一个制造商为我们签名的更新应用程序。更新应用程序在设备启动时运行,检查应用程序的当前版本和新版本,并在必要时安装新版本。
The use case would be a kiosk app, on tablets of one make and model, that don't have Google Play.
用例是自助服务终端应用,在没有 Google Play 的同一品牌和型号的平板电脑上。
回答by Rizvan
Google in 2018 Android dev summit announced android in-app update api's for developers so you can read whole story out here and get updated on this question.Android in-app update api details
谷歌在 2018 年 Android 开发者峰会上宣布了面向开发者的 android 应用程序内更新 api,因此您可以在这里阅读整个故事并获得有关此问题的最新信息。Android 应用内更新 api 详细信息
https://developer.android.com/guide/app-bundle/in-app-updates
https://developer.android.com/guide/app-bundle/in-app-updates