Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

Posts: 13
Registered: ‎06-11-2013
My Device: Blackberry 9300
My Carrier: Vodacom

Display image from URL on Blackberry screen



I recently started creating a new app and I use quite a few images in it. The problem is, using so many images cause the app size to be rathr bigger than what I'd like it to be, so I was thinking that using a URL connection to these images to display them, instead of adding all of them in the res folder will save a lot of space. However, I am still very new to Java and Blackberry development.


I have searched around a lot on Google and other sites like Stackoverflow, but none of those answers actually helped me. So basically my question is, how do I display an image from a URL (ex. www.picbase.com/mylogo.jpg) unto my screen? And how can I use a indicator like the ActivityIndicator to actually show that my app is trying to load something in the background? Can anyone maybe provide me with some useful example code that I could use? It will be appreciated very much.





Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Display image from URL on Blackberry screen

you would have to download the image first, displaying a web url directly is not supported.
see the httpdemo for a good start how to do that.

There is no (good) built-in indicator for something like that, so i would suggest taking a nice gif and displaying it in an animated state somewhere.
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Display image from URL on Blackberry screen

[ Edited ]

Search the forum for "image URL" as there are many other Threads on this or similar topics. 


This is the closest thing to what you want that I have seen:



However this code in itself has a number of things I don't like (for example, why convert to a String and then back to bytes), but it has the basics.  But even if you use this, if you have a page with loads of images you can run into errors with Threading, So for image processing like this you really need a Thread pool, and that all gets quite complicated.


Also of course, unless you 'cache' or store these images, each time the user runs your app, he or she downloads the images again.  For some apps of course, downloading them all the time is a requirement because they change. 


In your case, I suspect the images don't change, so I would consider a one off download, as part of the 'installation', then store the images on the SD Card.  If you think this is a good idea, then perhaps this sample will help:



Posts: 285
Registered: ‎08-26-2011
My Device: 9900
My Carrier: Not Specified

Re: Display image from URL on Blackberry screen



Bitmap Image not displaying from a URL link Blackberry


I think this one you are asking....!


Feel free to click LIKE button if the solution helps you;

Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Display image from URL on Blackberry screen

The way it reads the bytes was one of the other things that I did not like about the link I posted previously.  However there are issues with the code supplied above too.  For example:


int length=is.available();
byte[] data=newbyte[length];



Should in fact just be:



Downloading images on the fly is a nice idea in practice but has some significant issues.  So as I suggested, if you don't have to do it, don't.