以编程方式检查Android应用程序的最低要求版本并进行升级(Programmatically check for the minimum required version of an App for

编程入门 行业动态 更新时间:2024-10-25 22:34:52
以编程方式检查Android应用程序的最低要求版本并进行升级(Programmatically check for the minimum required version of an App for Android and upgrade it)

我有一个用例,我们希望有选择地禁用Android,直到用户升级到最低要求版本。 这个问题是为类似案例获取设计输入和最佳实践。

通常情况下,流程如下: -

启动应用程序后,主活动线程将检查当前安装的版本是否存在。 (我正在寻找指向Google API / TPL的指针,以便以编程方式实现此目的)。

然后,应用程序检查所需的最低版本。 (这可以通过维护休息服务所需的最低版本来完成)。 但是,是否可以在Play商店中维护所需的最低版本?

如果当前版本<min required version,则强制用户升级。 (将用户重定向到App Store并且不让他们回到应用程序直到他们升级 - 我也在寻找这种情况的代码指针)

请注意,这与应用商店中用于升级的推送通知不同。 与推送通知不同,此逻辑允许我的应用程序在我的用户群中保留一些最小版本。

I have a use case in which we wish to selectively disable an Android and an until the user upgrades to a minimum required version. This question is to get design inputs and best practices for similar cases.

Typically the flow will be as follows:-

Upon starting the app, the main activity thread will check the presence of the current installed version. (I am looking for pointers to a Google API/TPL to achieve this programmatically).

Then the app checks for the minimum required version. (This can be done by maintaining the minimum required version on a rest service). However is it possible to maintain the minimum required version on Play Store?

Force the user to upgrade if current version < min required version. (redirecting user to App store and not letting them back into the app till they upgrade - I am also looking for code pointers for this case)

Note that this is different from the push notifications from the app store for upgrades. Unlike push notifications, this logic will allow my app to stay at some min version across my user base.

最满意答案

如果您使用的是Android Studio,则可以使用以下代码检查应用当前版本

int versionCode = BuildConfig.VERSION_CODE; String versionName = BuildConfig.VERSION_NAME;

我不认为在Play商店中维护已安装的版本是可能的,所以使用rest api就可以了。

要强制用户更新应用程序 ,请使用api中的版本检查当前版本,如果不满足条件,请显示一个警告对话框,其中包含两个选项 : - 退出更新 。 要启动更新意图,您可以执行以下操作

Intent updateIntent= new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + your app package name));

更新:您还可以使用第三方库来检查更新。 我使用的是gpversionchecker

You can check current version of your app by using the following code if your using Android Studio.

int versionCode = BuildConfig.VERSION_CODE; String versionName = BuildConfig.VERSION_NAME;

I don't think maintaining installed version on play store is possible so using a rest api for this will be the option.

To force the user to update app, check current version with version from api, and if conditions are not met show them an alert dialog with two options:- either Exit or Update. To launch update intent you can do something like this

Intent updateIntent= new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + your app package name));

UPDATE: You can also use third party libraries to check for updates. One that I have used is gpversionchecker

更多推荐

本文发布于:2023-07-26 17:45:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1278879.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   最低   版本   方式   Programmatically

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!