如何从谷歌播放获得应用程序版本?

时间:2016-10-21 02:56:06

标签: android

我将我的应用程序添加到Google Play,现在我执行的操作包括添加新功能,新用户界面等,然后将应用重新上传到Google Play。

所以我想,当用户启动应用程序时,如果有新的更新,会有一个对话框显示提醒用户,允许他们更新最新版本。

Google似乎没有提供任何API来获取应用版本,所以有什么解决方案吗?

https://github.com/kloon/WooCommerce-REST-API-Client-Library

2 个答案:

答案 0 :(得分:1)

尝试将当前版本存储在其移动设备中,并在服务器中存储最新版本。

当用户启动应用程序时,检查它是否不同,应用程序将显示对话框以提醒使用下载最新应用程序。

编辑:

检查评论: https://stackoverflow.com/a/14512102/4531387

答案 1 :(得分:1)

使用Jsoup库并按照以下步骤操作:

1.在您的应用级别build.gradle

中添加依赖项
compile 'org.jsoup:jsoup:1.10.2'

2。在你的src中添加这个类

public class VersionChecker extends AsyncTask<String, String, String> {

private String newVersion;

@Override
protected String doInBackground(String... params) {

    try {
        newVersion = Jsoup.connect("https://play.google.com/store/apps/details?id=" + BuildConfig.APPLICATION_ID + "&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[itemprop=softwareVersion]")
                .first()
                .ownText();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return newVersion;
}}// add following lines to your code where you want to get live app version
VersionChecker versionChecker = new VersionChecker();try {
 mLatestVersionName = versionChecker.execute().get();} catch (InterruptedException | ExecutionException e) {
 e.printStackTrace();}
相关问题