BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 09-19-2008, 07:51 AM   #1
aur_bojan
New Member
 
Join Date: Sep 2008
Model: 7100T
PIN: N/A
Carrier: blackberry
Posts: 4
Default load picture from link

Please Login to Remove!

Hi!

I'm having this issue and I can't find a solution...
I would like to display an image to a blackberry device screen from a given link. For exemple I want to display the picture from the folowing address:

htt p://civquest.sourceforge.net/graphics/tiles/flat/ground/Mountain.png

I would appreciate some help.

Thanks!
Offline  
Old 09-19-2008, 08:02 AM   #2
goulamass
Talking BlackBerry Encyclopedia
 
Join Date: Jan 2008
Location: France
Model: 8310
PIN: N/A
Carrier: Vodafone
Posts: 217
Default

Hi,

In fact donwload th page and convert it into a picture

Code:
HttpConnection connection = null;  
            InputStream inputStream = null;  
            
            try  
            {  
                connection = (HttpConnection) Connector.open(url, Connector.READ, true);  
                inputStream = connection.openInputStream();  
                byte[] responseData = new byte[10000];  
                int length = 0;  
                StringBuffer rawResponse = new StringBuffer();
                while (-1 != (length = inputStream.read(responseData)))  
                {  
                    rawResponse.append(new String(responseData, 0, length));  
                } 
                    
                int responseCode = connection.getResponseCode();  
                if (responseCode != HttpConnection.HTTP_OK)  
                {  
                    throw new IOException("HTTP response code: "+ responseCode);  
                }     
                final String result = rawResponse.toString();
                    
                try  
                {  
                    byte[] dataArray = result.getBytes();  
                    EncodedImage encodedimage = EncodedImage.createEncodedImage(dataArray , 0 , dataArray.length);  
                    return encodedimage;
                        
                }  
                catch (final Exception e)
                {
                    return null;
                }  
            }
            catch (Exception e)
            {
                return null;
            }
Offline  
Old 09-19-2008, 08:31 AM   #3
aur_bojan
New Member
 
Join Date: Sep 2008
Model: 7100T
PIN: N/A
Carrier: blackberry
Posts: 4
Default

It works perfectly! You helped me a lot!

Thanks!
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Telemecanique (SQUARE D ) LC1D12G7 - CONTACTOR 120 V COIL - 3POLE picture

Telemecanique (SQUARE D ) LC1D12G7 - CONTACTOR 120 V COIL - 3POLE

$22.21



Advance Core & Coil Ballast Kit 1-400W M135 Metal Halide 71A6042-001D .Free Ship picture

Advance Core & Coil Ballast Kit 1-400W M135 Metal Halide 71A6042-001D .Free Ship

$39.99



1100-0541 6 Volt Ignition Coil for Ford Tractor 2N 8N 9N Front Mount 9N12024 picture

1100-0541 6 Volt Ignition Coil for Ford Tractor 2N 8N 9N Front Mount 9N12024

$27.36



AC HVAC Coil Cleaning System Automotive Pressure Washer Machine 145 PSI w/Hose picture

AC HVAC Coil Cleaning System Automotive Pressure Washer Machine 145 PSI w/Hose

$155.99



Heating Coil 5 PIN XLR 20mm 16mm 10mm flat 25mm 30mm Electronic picture

Heating Coil 5 PIN XLR 20mm 16mm 10mm flat 25mm 30mm Electronic

$34.99



LC1D258G7  4 POLE CONTACTOR  120V COIL 50/60HZ. SCHNEIDER picture

LC1D258G7 4 POLE CONTACTOR 120V COIL 50/60HZ. SCHNEIDER

$114.99







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.