我如何从Google Play商店获取应用程序版本信息,以便在更新Play商店应用程序时(即在用户使用旧版本应用程序的情况下)提示用户强制/建议对应用程序进行更新。我已经经历过andorid-market-api,这不是官方方法,并且还需要Google的oauth login身份验证。我也经历过android query
它提供了应用内版本检查功能,但在我的情况下不起作用。
我发现了以下两种选择:

  • 使用服务器API来存储版本信息
  • 使用google标记并在应用程序内访问它,这不是首选方式。

  • 还有其他简便的方法吗?

    最佳答案

    我建议不要使用库只是创建一个新类

    1。

    public class VersionChecker extends AsyncTask<String, String, String>{
    
    String newVersion;
    
    @Override
    protected String doInBackground(String... params) {
    
        try {
            newVersion = Jsoup.connect("https://play.google.com/store/apps/details?id=" + "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();
        } catch (IOException e) {
            e.printStackTrace();
        }
    
        return newVersion;
    }
    
  • 在您的 Activity 中:
        VersionChecker versionChecker = new VersionChecker();
        String latestVersion = versionChecker.execute().get();
    

  • 就这些

    10-07 19:13
    查看更多