android应用商店检查更新,以编程方式检查Play商店中的应用更新

18a88f1fe8d91a317546cc7994d00609.png

跃然一笑

在您的应用程序build.gradle文件中包含JSoup:dependencies {    compile 'org.jsoup:jsoup:1.8.3'}并获得当前版本,例如:currentVersion = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;并执行以下线程:private class GetVersionCode extends AsyncTask {    @Override    protected String doInBackground(Void... voids) {        String newVersion = null;        try {            newVersion = Jsoup.connect("https://play.google.com/store/apps/details?id=" + MainActivity.this.getPackageName() + "&hl=it")                    .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();            return newVersion;        } catch (Exception e) {            return newVersion;        }    }    @Override    protected void onPostExecute(String onlineVersion) {        super.onPostExecute(onlineVersion);        if (onlineVersion != null && !onlineVersion.isEmpty()) {            if (Float.valueOf(currentVersion) < Float.valueOf(onlineVersion)) {                //show dialog            }        }        Log.d("update", "Current version " + currentVersion + "playstore version " + onlineVersion);    }有关更多详细信息,请访问:http : //revisitingandroid.blogspot.in/2016/12/programmatically-check-play-store-for.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值