如何从 Google Play 商店获取应用市场版本信息? [英] How to get app market version information from google play store?
问题描述
如何在更新 Play 商店应用程序时,即用户使用旧版本应用程序时,从 google Play 商店获取应用程序版本信息以提示用户强制/建议更新应用程序.我已经通过 andorid-market-api 这不是官方方式并且还需要来自谷歌的 oauth login 身份验证.我也经历过 android 查询它提供应用程序内版本检查,但在我的情况下不起作用.我找到了以下两种选择:
How can I get the application version information from google play store for prompting the user for force/recommended an update of the application when play store application is updated i.e. in case of the user is using old version application. I have already gone through andorid-market-api which is not the official way and also requires oauth login authentication from google. I have also gone through android query which provides in-app version check, but it is not working in my case. I found the following two alternatives:
- 使用将存储版本信息的服务器 API
- 使用谷歌标签并在应用内访问它,这不是首选方式.
还有其他方法可以轻松做到吗?
Are there any other ways to do it easily?
推荐答案
我建议不要使用库,只需创建一个新类
I recomned dont use a library just create a new class
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;
}
在您的活动中:
In your activity:
VersionChecker versionChecker = new VersionChecker();
String latestVersion = versionChecker.execute().get();
仅此而已
这篇关于如何从 Google Play 商店获取应用市场版本信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!