0

I am retrieving android apps icons using this code :

Drawable icon = icon = p.applicationInfo.loadIcon(context.getPackageManager());

where p is PackageInfo class object.

I have implemented a server for android which handles requests and responses by client. Here when I send a GET request from client that is my browser, server generates a html page.

Problem is that I need to display retrieved android installed App Icons on html page and I used the following code to do that:

returnHtml += "<tr>";
returnHtml += "<td><img src=" + icon +" /></td>";
returnHtml += "<td>" + apps[0] + "</td>";
returnHtml +="<td>" + apps[1] + "</td>";
returnHtml += "<td>" + apps[2] + "</td>";
returnHtml +="<td>" + apps[3] + "</td>";
returnHtml +="</tr>";

Basically, here I am generating a table row with respective app info and displaying respective App icons in first column.But it's not showing respective App icons instead displaying default icon image (small image with a question mark on it).

"icon" is a "Android Drawable" class object. Do I need to convert retrieved icon to some form or I need to store icon in some folder first ?

As my html pages are stored in assets folder which is not writable I can't store icon images there. Is there any solution to display icon images directly from drawable object only ?

hasanghaforian
  • 13,858
  • 11
  • 76
  • 167
Hapie
  • 35
  • 1
  • 8

1 Answers1

0

Are you using fromHtml? http://developer.android.com/reference/android/text/Html.html#fromHtml(java.lang.String, android.text.Html.ImageGetter, android.text.Html.TagHandler)

There's an argument for Html.ImageGetter which allows you to resolve the src string into a Drawable.

noisecapella
  • 814
  • 7
  • 17
  • @noisecapella : No I am not using fromHtml. I want to set drawable to html as said by Calvin. – Hapie Jul 17 '12 at 14:32
  • Is this helpful? http://stackoverflow.com/questions/6127696/android-local-image-in-webview – noisecapella Jul 17 '12 at 14:34
  • @noisecapella : that link provide information regarding how to load image from stored in assets folder and I don't have image in assets folder.Here I am getting image in Drawable object "icon" which I can't store in assets folder as it is not writable one. So problem is how to set Drawable to html. – Hapie Jul 17 '12 at 14:41