为了账号安全,请及时绑定邮箱和手机立即绑定

android - 更新按钮未显示在 Google Play 商店中

android - 更新按钮未显示在 Google Play 商店中

慕神8447489 2023-06-14 15:42:23
我在我的 Android 应用程序中进行了强制更新,它会在 Play 商店中检查我的应用程序的版本名称,并通过我的应用程序更新进行验证。如果 google play 商店版本与当前版本不同,它会显示更新的弹出消息。当用户按下弹出窗口上的更新按钮时,它会重定向到 Play 商店。问题是,在 google play store 上,在某些设备中,“更新”按钮不显示,而显示“打开”按钮。我尝试清除缓存,它起作用了。但是对于用户来说也不是很方便。在多少台设备上,我必须继续这样做。这是我下面的代码,用于验证应用程序版本:protected String doInBackground(String... urls) {        try {            newVersion =  Jsoup.connect("https://play.google.com/store/apps/details?id=" + <Your package name> + "&hl=en")                    .timeout(30000)                    .userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")                    .referrer("http://www.google.com")                    .get()                    .select("div.hAyfc:nth-child(4) > span:nth-child(2) > div:nth-child(1) > span:nth-child(1)")                    .first()                    .ownText();            return newVersion;        } catch (Exception e) {            e.printStackTrace();            return "";        }    }这是重定向到 google play 商店的代码:try {                Intent intent = new Intent(Intent.ACTION_VIEW);                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);                intent.setData(Uri.parse("market://details?id=" + context.getPackageName()));                startActivity(intent);                dialog.dismiss();            } catch (Exception e) {                e.printStackTrace();            }正如我已经告诉过你的那样,在某些设备上它工作正常,而在某些设备上,我必须清除 Google Play 商店缓存。什么是理想的解决方案?
查看完整描述

1 回答

?
呼唤远方

TA贡献1856条经验 获得超11个赞

根本不推荐你在做什么。

您正在尝试抓取网站以搜索特定的 HTML 或 CSS 标签,这些标签是自动生成的,并且每次构建播放网站时可能会有所不同,并且在基于为页面提供服务的服务器的不同版本的 PlayStore 之间,这可能会破坏您的任何逻辑片刻。

处理这种情况的正确方法是使用适用于 Android API >= 21 (Lollipop) 和适用于 Android < 21 的应用内更新库,使用你自己的后端和 REST API,可以查询它以获得最新的可用版本。

您看到的问题可能与您的逻辑在某些情况下从 PlayStore 读取错误值有关。


查看完整回答
反对 回复 2023-06-14
  • 1 回答
  • 0 关注
  • 76 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信