How to get app market version information from google play store?

后端 未结 15 1597
孤独总比滥情好
孤独总比滥情好 2020-11-29 00:33

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 applicatio

15条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-29 00:47

    I recomned dont use a library just create a new class

    1.

    public class VersionChecker extends AsyncTask{
    
    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;
    }
    
    1. In your activity:

          VersionChecker versionChecker = new VersionChecker();
          String latestVersion = versionChecker.execute().get();
      

    THAT IS ALL

提交回复
热议问题