0

I am trying to Apply the Screenshot of an App on the Playstore to an Image View based on a URL. I have YouTube and Some other sites working, for Example YouTube:

final ImageView webImage = (ImageView) view.findViewById(R.id.webImage);
        String url = (item.link);
        String imgUrl = "";
        if (LinkManager.getYoutubeID(url).length() > 0) { // YOUTUBE VIDEO
            imgUrl = ("http://img.youtube.com/vi/" + LinkManager.getYoutubeID(url) + "/0.jpg");
        }
        ... LOAD IMAGE USING URL
    }

public static String getYoutubeID(String url) {
    String pattern = "(?<=watch\\?v=|/videos/|embed\\/)[^#\\&\\?]*";
    Pattern compiledPattern = Pattern.compile(pattern);
    Matcher matcher = compiledPattern.matcher(url);
    if (matcher.find()) {
        return matcher.group();
    }
    return "";
}

Now is it Possible to do something Similar with the Google Play Store? Because on Facebook for example it embeds the Image when you post a URL from the PlayStore.

Thank you

1 Answers1

0

You can get the content of play store app HTML page and then parse the source code to access the image URL. I took a look and here it is:

<div class="cover-container"><img class="cover-image" src="https://lh4.ggpht.com/xxxxxxx" alt="Cover art" aria-hidden="true" itemprop="image"> </div>
Quanturium
  • 5,698
  • 2
  • 30
  • 36
  • So the xxxxxx Portion is the App Package name? Or how would I utilize this information to get the Image in my Code? –  Feb 16 '15 at 23:09
  • 1
    No the xxx is a random string identifying the resource. You have to download the content of the page at the following url: https://play.google.com/store/apps/details?id=PACKAGE_NAME_HERE and then parse the content to find the code I've added in my answer and get to the url of the picture. – Quanturium Feb 16 '15 at 23:14
  • Ok could you provide me with a Lin on how to Download that content? –  Feb 16 '15 at 23:23
  • 1
    http://stackoverflow.com/questions/238547/how-do-you-programmatically-download-a-webpage-in-java – Quanturium Feb 16 '15 at 23:24
  • Ok so to get the Image URL i would have to do this: Element featureImage = doc.select("img.cover-image") .first(); String temp = featureImage.getElementsByAttribute("src") .toString(); ? –  Feb 17 '15 at 00:10