Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>//YOUR PACKAGE NAME package ...........; //************************* import java.io.InputStream; import javax.microedition.io.Connector; import javax.microedition.io.HttpConnection; import net.rim.device.api.system.Bitmap; public class Util_ImageLoader { public static Bitmap getImageFromUrl(String url) { Bitmap bitmap = null; try { String bitmapData = getDataFromUrl(url); bitmap = Bitmap.createBitmapFromBytes(bitmapData.getBytes(), 0, bitmapData.length(), 1); } catch (Exception e1) { e1.printStackTrace(); } return bitmap; } private static String getDataFromUrl(String url) { StringBuffer b = new StringBuffer(); InputStream is = null; HttpConnection c = null; long len = 0; int ch = 0; try { c = (HttpConnection) Connector.open(url); is = c.openInputStream(); len = c.getLength(); if (len != -1) { for (int i = 0; i &lt; len; i++) if ((ch = is.read()) != -1) { b.append((char) ch); } } else { while ((ch = is.read()) != -1) { len = is.available(); b.append((char) ch); } } is.close(); c.close(); } catch (Exception e) { e.printStackTrace(); } return b.toString(); } } </code></pre> <p>copy this to your package.... Now, to use this class do like this>>>>>>>></p> <p><strong>CREATE BITMAP OBJECT:</strong></p> <pre><code>Bitmap IMAGE; </code></pre> <p><strong>After That:</strong></p> <pre><code>IMAGE=Util_ImageLoader.getImageFromUrl("https://graph.facebook.com/100003506521332/picture"); </code></pre> <p>By the way, I think you have missed extension like JPG,PNG, on your URL.... Check That</p> <p>Now, add your bitmap where you would like to display the image......</p> <p>ENJOY!</p> <pre><code>add(IMAGE); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload