且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android 应用程序版本更新服务,无需将其发布到市场

更新时间:2023-09-21 11:24:16

我发现***的方法是托管 apk 和带有最新版本 # 的文本文件.

The best way to do this I have found, was to host the apk and a text file with the latest version #.

打开应用程序后,将当前的 v # 与服务器上托管的 v # 核对,如果它们不匹配,请获取新的 v#.

Opon opening the app, check the current v # against the one hosted on the server, if they dont match, grab the new one.

除非您的应用作为后台服务运行,否则无需推送任何内容,并且您需要确保用户是否使用最新版本,无论他们是否使用它.

No need for pushing anything unless your app works as a background service and you need to ensure that whether the user is on the latest version whether they use it or not.

如果是这种情况,您可以使用每天执行一次或类似的服务.

If that is the case, you can have a service that does it once a day or something like that.

编辑 - 下载后,要安装 apk,请使用以下代码.

EDIT - after downloaded, to install the apk, use the following code.

Intent promptInstall = new Intent(Intent.ACTION_VIEW)
    .setDataAndType(Uri.parse("file:///path/to/your.apk"), 
                    "application/vnd.android.package-archive");
startActivity(promptInstall); 

在 Android 上以编程方式安装应用程序