Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the applications icon from the Google play dynamically

I'm developing an application that show a list of applications, and I want to get the Icon of this applications from the Google play store to show it in the list, so if there are any way to do that please tell me.

like image 293
Mahmoud Jorban Avatar asked Feb 17 '13 09:02

Mahmoud Jorban


People also ask

Can I change app icon dynamically in Android?

In this article, we are going to learn how to change the App Icon of an App on the Button Click. This feature can be used when we have an app for different types of users. Then as per the user type, we can change the App Icon Dynamically.

Can I change app icon Google Play?

Tap the app name whose icon you want to change. Select Icon from the settings menu that opens. The available icons for that app from the various icon packs installed on your phone appear under the Available Icons section. Select the one you like.


1 Answers

I had to tackle this problem myself recently in updating my portfolio website, so i even have some code for you :) What i did was in php but i'm not sure what you want to use. First i checked the source of the page with my app on it using view->developer->developer tools (on chrome). Then using that i could traverse the DOM looking for something i could use to identify the app icon. I found this: screenshot

what this showed is that the app icon was held inside a div with class "doc-banner-icon" - I couldn't find this class anywhere else, so i take it for granted that it is the only div with that class. Then in my php code i used simpledomparser to load the url, locate the icon and spit out it's url, like so:

<?php
include('simple_html_dom.php');

$html = file_get_html("https://play.google.com/store/apps/details?id=com.smithyproductions.swissarmycarrot"); //put your app id here

$bannerImage = $html->find('.doc-banner-icon'); //the class we found before

$img = $bannerImage[0]->find('img'); //find the img tag inside the div

$imgUrl = $img[0]->src; //get its src url

$arr = array(); //in my own example I filled this array with other things like the title an screenshots

$arr['imgUrl'] = $imgUrl;

echo json_encode($arr); //output it in an easy to read format

?>

resulting in something like
{'imgUrl','https://lh6.ggpht.com/1WMU4E3lnbjz5yxLHxsPrJAJPw3uYZ8LXk3QkD1EKOxwOcHu0W9QyGlpM5AfrKYEVzzi=w124'}

Just one thing to bear in mind about this approach: Google could change the way everything is presented and laid out at any time so prepare to update your app when this happens :)

like image 114
roarster Avatar answered Oct 13 '22 07:10

roarster