A gif of url retrieval problem?

Hello, any help is appreciated...
I'm trying to get a GIF image from a url ( http://www.google.com/ig/images/weather/mostly_cloudy.gif )
my program retrieves the GIF image from the url (the type of result is STRING)
so I use getBytes() to get the bytes of the request was successful.
but when the program reached EncodeImage and the application throws exceptions...
Here's the code: (hope you can help)

--------------------------------------------------
function that converts the string to a bitmap (String imageData) {}

Byte [] b = imageData.getBytes ();
-

EncodedImage response = EncodedImage.createEncodedImage (b, 0,
b.Length);

If (response! = null) {}
System.out.println ("connection succeeded...");
IMG = response.getBitmap ();
}

}

--------------------------------

That's how I connect to the internet

public static String getDataFromUrl (String url) {}

StringBuffer b = new StringBuffer();
InputStream is = null;
C HttpConnection = null;

Len length = 0;
int ch = 0;
try {}

c = (HttpConnection), Connector.open (url);

int rc = c.getResponseCode ();

is = c.openInputStream ();
Len = c.getLength ();

If (len! = - 1) {}
Read exactly Content-Length bytes
for (int i = 0; i)< len;="">
If ((ch = is.read (())! = - 1) {}
b.Append ((Char) ch);
}
} else {}
Read until the connection is closed.
While ((ch = is.read (())! = - 1) {}
Len = is.available ();
b.Append ((Char) ch);
}
}

is. Close();
c.Close ();
Return b.toString ();

} catch (IOException e) {}
System.out.println("---Connection_Error");
Return "Connection_Error";
}

System.out.println("---Connection_Error_closed");
Return "Connection_Error_closed";

}

Hi, This will work fine. I have tested it also now.

 If you liked my post and found it useful please click on the thumbs up and provide a Like!
public static Bitmap downloadImage()
    {
        InputStream iStream = null;
        EncodedImage bitmap;
        Bitmap bmp = null ;
        HttpConnection httpConnection = null;

        try
        {
            httpConnection = (HttpConnection) Connector.open("http://www.google.com/ig/images/weather/mostly_cloudy.gif"
                    +ConnectionInfo.getInstance().getConnectionParameters(), Connector.READ_WRITE);

            httpConnection.setRequestMethod(HttpConnection.GET);
            int responseCode = httpConnection.getResponseCode();
            if (responseCode == HttpConnection.HTTP_OK) {

                iStream = httpConnection.openInputStream();

                byte[] imageData =  IOUtilities.streamToBytes(iStream);
                bitmap = EncodedImage.createEncodedImage(imageData, 0, imageData.length);
                bmp = bitmap.getBitmap();

            }
        }
        catch (Exception e)
        {
            System.out.println("error:"+e.getMessage());
        }
        return bmp;
    }

Tags: BlackBerry Developers

Similar Questions

  • In Streaming URL access problem

    I'm developing an audio application for the Webkit browser HTML5-based streaming.

    This application allows the user to select the URL about 500 each belonging to a different radio station.

    The problem is that if everything works as expected in the simulators, audio streams don't come throug when a test is performed on a real blackberry. Of the app to different URLS external links to retrieve image of radio station logos, but audio external URLS do not work. I've had two users try on two different blackberries with the same result. They use the OS6 and OS7 so these are the two new phones. Can someone tell me what could go wrong?

    Looks like I need set the permissions of the configuration file, after doing some research on this site.

    It's something youdon t need to do this when you use the simulators.

  • URL WRT310N problem

    Well, this is my second WRT310N (version 2), I couldn't believe that this thing was so bad that he acted with the first one I got (and back), so I try again.

    The first thing I get after the router has been completely configured, internet "worked" was:

    URLThe Invalid URL requested ' / ', is not valid.

    Reference #9.6c6d1160.1250371680.0

    by clicking on my bookmark yahoo.com or hit 'home' on any of my browsers (Chrome, Firefox, and IE8 all "original" is set to www.yahoo.com).  I have ping would be yahoo.com in a window DOS command and got the IP digital and was able to go.  But not from www.yahoo.com.  And other URL like google.com, facebook.com, etc are fine.  Same "us.yahoo.com" works very well.

    Only a reboot will fix it.  And then only for a while... 20 minutes later, I have experienced the same problem, click on yahoo.com and get "invalid URL".

    Has anyone else experienced this problem and solved, or Version 2 of this router is just a piece of junk?

    I'm perfectly willing to work with this, but it goes back to the store pretty soon if I can't get out of frequent reboots.  If it wasn't the second router I had who encounters this problem, I have undertaken my own mental health.

    Thank you.

    -Roger

    Yes, when I disabled the firewall and antivirus disabled, my regular www.yahoo.com link was broken again.

    I solved this problem by opting for a Dlink DIR-655 Router, no problems now.  I can go wherever I want to, I have the gigabit wired ports that I was looking for, and I have n wireless.  It's nice not to have to wince before clicking on a URL.

    I think that there is something seriously wrong with the firmware for version 2 WRT310N router.  Or maybe I had 2 guys that Linksys extinguish.  I'm dubious on this subject, I have it from very different sources.  I have not seen the specific problem I had with the WRT54GS Linksys or Dlink DIR-655, so I'm pretty darn sure that points to the problem being the version router WRT310N 2 somehow.

    Thank you for trying to help, there is no help for this problem.  I really tried to make the WRT310N I got work, both were defective in exactly in the same way, this is why I finally gave up.

    -Roger

  • URL parameter problem

    Hello

    I'm new to the development of blackberry applications. I try to access a Web service, I can access using the http connection. When passing a parameter in the URL includes only one word then it works fine and answers correctly, but when I pass the same variable with a different value that contains several words separated by space, then it generates an error. I tried to pass the same URL in the browser, but the browser gives me good performance.

    I believe strongly that there is a problem when the parameter is sent. Please help me

    Thanks in advance

    If you only want to add parameters using percent encoding:

    http://en.Wikipedia.org/wiki/percent-encoding

  • Streaming and URL redirection problem

    Hello

    I have a problem with an application that I have developed, the application plays a remote mp3 file via the player class (player player = Manager.createPlayer (url); player.start ();) but to access the url of the file physical I follow two different redirects.

    Is there a way for the player to follow automatically the different redirects or I need to manipulate them manually

    Thank you

    Abdeslam Jakjoud

    Unfortunately, you face within your application. Please refer to this topic too. http://supportforums.BlackBerry.com/T5/Java-development/RTSP-player-can-redirect/m-p/1380467#M179370

  • URL monitor problem

    Hello

    I have a problem with the url monitors in sitescope 11.12.I have a lot of monitors, but occasionally monitors URLs go to error status and send email... a lot of e-mails due to the large number of monitors. When I go to the details of every monitor I see that status has value of sub zero (for the most part-1) and I have no idea why, because when I run a monitor manually, he goes to the good condition and everything seems to be ok. I am flooded with e-mail messages, and helps the single server restart. After the reboot, everything is ok... for the next ~ 12 h. Then it goes crazy again... and again reboot and still ok and so on and so forth. I did not any changes in SiS recently. I've seen is that, when I go to Network Status Tool, there are dozens of connections which are in a State of "TimeWait". Operating system is windows server 2003 64-bit. Please help me, I can't stand these emails any more ;-)

    Thanks in advance,
    Przemysaw

    Hello Przemysaw,

    It's the level of consumer forums.

    Your question is better asked in the Forums of company/Business more here.

  • APEX URL SYNTAX PROBLEM

    APex 4.2

    I think I still have a problem with the syntax of URL Apex. I have a question where I am a link within the query and try to get inside several pairs of element value. I have no problem passing a pair of point value, but when I try to do multiple, I have a problem. My query is below:

    SELECT project_id, content_type,
    '<a href="javascript:apex.submit({request:''SAVE'',set:{''P3_GO_TO_FL'':'''||'Y'||''',''IREQ_PROJECT_ID'':#PROJECT_ID#}});">Project</a>' as "Project Link"
    FROM MY_TABLE
    WHERE THIS_ID = :P3_ID
    
    

    I feel as if there's some place apostraphes. I tried a variation of things, but I just don't get it. I had a similar problem before, but it is within a link of the column. It is within a query which I assume has something to do with why my syntax was interrupted. Any help on this would be greatly appreciated. Thanks in advance

    OK, so I made some progress. Consider the following query:

    SELECT project_id, content_type,
    case
       when content_type is not null then 'Not Null Case'
       else 'Null Case'
    end as "TESTING_QUERY"
    FROM THIS_TABLE
    WHERE THIS_ID = :P3_THAT_ID
    

    So I'm still trying to build a link inside a query (don't see any solution to my problem). I have two branches. One who makes something when the value of the indicator is set on 'Y' and a branch that made another when the value of the indicator is set 'n'. In my case, 'Y', the content_type must be passed in a page element. The syntax is correct. The only problem is that the string substitution #CONTENT_TYPE # gives me problems. I don't know if this should be a substitution string or not, but I know that if I had to replace this with a random value, that random value substitution string passed to the order of the day of the P3_CONTENT_TYPE page (I tried several times) and I am able to use/view the content of this page P3_CONTENT_TYPE element. Even when I fly over my link, the url is correct, but instead to display the actual value of the substitution string, it just shows "#CONTENT_TYPE # Rather than use the substitution string my request, I also tried to use 'content_type' but is not no longer works.

    It is the last problem or obstacle that I am jumping. Getting the substitution string to display real value would be solve my problem overall. Any ideas on what could be the problem?

    Thanks in advance.

    As soon as I posted this, I've done a few steps more and I realized what the problem was. This is the syntax of the query. I guess that it will not allow you to use a substitution string. Must concatenate it thus:

    SELECT
    ....
    ....
    when content_type is not null then 'Not Null Case'
    else...
    end as..
    ....
    ....
    

    This is the correct syntax... I guess I should since I'm pulling the value of content_type itself in the actual query. But it works for me. Maybe not the best way, but it solved my problem. Thanks for your help. Maybe this will be useful to someone else.

  • File published by aggregator has URL link problems

    I published a file via the aggregator to combine two files together in a single .swf. It works fine, but the URLs of web on the slides have now stopped working.

    I hover over them in a web browser and the hand cursor rises, recognizing that a link is there, but pressed once nothing happens.

    The links work in Captivate when I play there, but not when I try to play through a web browser.

    Any ideas?

    See you soon

    Jonny

    Have you added the publication record as a trusted location in your Flash Global security settings?

    Otherwise, you test on your hard disk or LAN, and this is probably the cause of the problem.

  • GIF/save for Web problem (PSE 7)

    I tried searching for an answer to this problem, but nothing seems to fix everything that happens.

    Recently, I had to replace my laptop and from Windows XP to Windows 7.  I transferred the PSE 7 from the old system to the new system and have had no problems with it - until now.  I have an image in format Photoshop 52 - layer I want to save as an animated .gif, with each layer as a different image.  File > > Save As has the ability to save layers as frames, but if I check it, then click on 'Save', nothing happens.  Nothing at all.  On my old system, I would get a new dialogue with options like the quality, duration by frame, loop, etc., but that doesn't happen any more, and there is nothing to save (if I'm going to find the new .gif file, it's just not there). If I do not choose "Layers in images", dialogue .gif does so very well and it has no difficulty to save it as a static .gif file.  But it seems that she won't just save it in animated format.

    I'm having the same problem with "save for Web".  Or the option of the file menu or typing command will bring up dialogue to let me record this way.  He thinks maybe a second, but does nothing else and does not record the image.

    I tried to reset the layout, just in case the dialog box has been moved somewhere that I wasn't just to see and I tried to reset the preferences to save it for the Web, but none of these things worked.  No explanation as to why a .gif animation 'layers as images"is the only format that is not saving correctly?

    I also tried old connections animated that I created with XP, and they will not re - save as animation connections either opening.  I get her "do you want to save changes" dialogue, but clicking on 'Yes' does nothing and does not record updates.  I am at a total loss for why this feature no longer works.

    If you right click on the shortcut of items and choose Run as administrator,

    It does make a difference or not save for Web work?

    Registration of the Web dialogue box is the same dialog box that you would get when checking the layers as frames

    in the Save as dialog box.

    MTSTUNER

  • animated GIF and color gradient problem

    Hello

    I tried to create a gif animated with gradient background. My animation works fine but the problem is that when I saw either in the browser or in preview mode, the gradient is not smooth. I want to know if there is a way around this? I've seen some on other sites, and it seems perfect. I wonder how they do it.

    I will appreciate help from anyone.

    Fred Cobby wrote:

    I have to thank you all for your help so far. I have to say, I know only how go back a certain number of things and I do not understand some of the technical terms you used as dither, dither geometric, blending mode... But overall, I understand that if I mix colors that are close, I will have something close to smooth.

    Here is the Wikipedia page on a dithering: http://en.wikipedia.org/wiki/Dither scroll down until you see the pictures of cats on the right side. It's a little more to halfway. In the original, the cat is pretty much a gradient. If this image is saved as a .gif file, see how to get large areas of color? It looks almost like a paint-by-numbers picture. This similar to what is happening to your radial gradient when you save in .gif. I used the "geometric" Word, because the radial gradient will produce gray colors arcs. The third picture of the cat has the dithering. This means that, instead of setting the colors of the original image to the one closest in the limited palette, the software tries to understand how speckle image in order to produce an average which would be better at a distance. Plug the dithering when you go to the output that your gradient will help make your smoother image, just like the third image of the cat is more fluid than the second. This is where you turn on the dither if you go through file > preview image:

    Here I have my not flattened .png file

    No, it is flattened. It's a single bitmap.

    This is a noisy image, I created. It has a radial gradient at the bottom, then a layer of texture that has its visibility, because I copied it to a grayscale version to use. I set myself to have 25% opacity and a Multiply blending mode. The opacity and the merger of mode controls are at the top of the layers panel. It is a FW .png (Edit, no, it isn't!) The forum continued to support that! ):

    If I export the gradient alone, without the texture layer, I get this (parameters are '64-color' gray palette and no dithering):

    or that (turning dithering):

    While the tone is better, it still shows the arcs. If I put the layer of texture visible return and export with dithering, I get this:

    The noise in the texture breaks geometric arches, that makes the smooth image. Any small texture will do it. Choose the 64 levels of gray color palette gives me colors either 22 or 26. The 32 color palette gave me 12. You should experiment with .gif palette settings to see which you like the most. Remember the colors more you assign to your background colors as you have for your first plan objects.

    As a final point, the red text appears blurred. When I Zoom in on it (400%), some lines are partially "broken," specifically the verticals on the L, T and N. You might want to try a different font or by adjusting the height so that aliasing (mapping) to the pixels is cleaner. Text in italics in small size is difficult to use.

  • URL Navigation problem GO

    I started using a URL to GO for the first time. I raised my issues in this forum as well and some articles online.

    So I wanted to pass the filters of a report to another via a URL.

    So in the report the brand column must be transmitted to the other report.

    If in the column of the brand formula, I replaced it with this

    ' <-a href = "http://mgd-1560b7b78e:9704/analytics/saw.dll?Go & Path = / users/admin/sales summaries/Central region of sales of $/ central region districts Sales Summary & Action = Browse & P0 = 1 & P1 = eq & P2 = Products.Brand" > ' <-/a > ' (I had the '-' only here to view)

    and in the format of column, I changed to HTML. I see no problem with my syntax that there aren't any errors

    I have not until here no error, but the brand column is empty.

    I expected to see values of the brand with a link on this interaction so that when you click on it, it will take me to the other report mentioned in the path, passing the value of the brand clicked

    Please guide me if I am missing something here

    Thank you
    Prash

    Published by: Prash11 on May 10, 2010 13:52

    I agree with BIPuser. You didn't get a GoURL format. P0 - the number of parameters, and then must follow the triplets: P1 - P2 - operator ., P3 - the value and so on. If your link – '<--a href="http://mgd-1560b7b78e:9704/analytics/saw.dll?Go&Path=/users/administrator/Sales Summaries/Central Region Sales by dollars/Central Region Districts Sales Summary&Action=Navigate&P0=1&P1=eq&P2=Products.Brand">'<-->'-incorrect. You did not show a parameter P3.
    BIPuser wrote a correct link but with some errors:
    (1) P0 should be 1
    (2) I guess all spaces in a link must be replaced with % 20, or the link must be a quote unquote - '(or 22%)
    So the correct link, I guess that
    '<--a href="http://mgd-1560b7b78e:9704/analytics/saw.dll?Go&Path=/users/administrator/Sales%20Summaries/Central%20Region%20Sales%20by%20dollars/Central%20Region%20Districts%20Sales%20Summary&Action=Navigate&P0=1&P1=eq&P2=Products.Brand&P3='||Products.Brand||'">'|| Products.Brand |' <-->'

    I hope this helps.

  • URL redirection problem

    Hello

    I try to redirect to a URL (preferably in a new browser window), but can not get the URL that will be built correctly. When I try to use a button and put something like this into the URL field target: -.

    http://emasanwkdfllh0.EMEA.com:7055/TOU/SWF/TouClient.HTML?view= & p4_tou_vil_id.%3A & p4_tou_vil_name.

    As suggested in a response to a similar question in another thread, the URL that is generated contains actually the chains '& p4_tou_vil_id.' and '& p4_tou_vil_name.', rather than the content of these two pages of items. I checked items contain the appropriate values, using the session button in the toolbar of developers, but when I hover over the button, the displayed URL has the channels above, and when I click the button, the application that is started will fail because it does not include the values passed to it - he expects, for example "55" and "COPD". , but receives "& p4_tou_vil_id." and "& p4_tou_vil_name."!

    I tried to use ": p4_tou_vil_id" and even "#p4_tou_vil_id #", but they also end up by directly in the URL.

    I also tried to use a HTML region, put the following (without the ' _' in 'h_ref') in the area of the source as follows: -.

    < a_href = "http://emasanwkdfllh0.emea.pfizer.com:7055/tou/swf/TouClient.html?view= & p4_tou_vil_id.%3A & p4_tou_vil_name" > parcel TOU < /a >

    This suffers from the same problem as above.

    What is the schoolboy error I get here?

    Thank you

    SID.

    Sorry for this Sid: P

    Well, in the URL of your button target when you use
    JavaScript:Redirect('http://emasanwkdfllh0.EMEA.com:7055/tou/swf/TouClient.html?View=148:prostate_or_Kidney_Disorder_Target...)

    Replace it with the function below and replace the Google URL in single quotes with your URL. No target = "_blank" is required - just your URL in single quotes.

    JavaScript:popupURL('http://www.google.com')

    I hope this helps.

    -Chris

  • GIF in Photoshop rendering problem

    I did a smoke effect using a gradient in Photoshop CS6 brush. When I tried to make it as gif, the smoke turns into a white solid color. How to preserve the fade effect? Please help me.

    Source language

    Screen Shot 2015-12-29 at 1.03.45 PM.png

    Optimized (after the release of rendering/fini)

    Screen Shot 2015-12-29 at 1.03.51 PM.png

    My suggestion works for static images - not for the animations. For entertainment, you're out of luck.

    To make this work with totally transparent animated images, you will need to use a CSS sprite (which is not really possible in your case, because the size would be too big), or export to a movie file that supports alpha transparency. But this is is not supported in browsers either.

    You can operate it by dithering from the effects of smoke, at the expense of quality. Or use javascript to create the animated sequence (ReelJS would work: jQuery reel Plugin).

    In any case, that the animation of yours would still be quite large and slow to download. Another option is to make the effects of smoke with javascript separately.

  • &amp; in the url, creating problems of XInclude.

    Hello

    Can someone tell how to fix this?
    <?xml version="1.0"?>
    <check xmlns:xi="http://www.w3.org/2003/XInclude">
    <xi:include href="abcd.jsp?var1=value&var2=value2" />
    
    </check>
    I get the following error.
    parser error: EntityRef: expecting ';'
    abcd.jsp?var1=value&
                                ^
    How to pass several parameters in the url I specify in the href?

    Thanks in advance,
    Divya.

    Hello

    Ampersand () must be escaped from the valid XML:

    
    
    
    
    
    
  • Workspace URL parameter problem!

    I have a URL like this:

    http://localhost: 8080 / Workspace? startEndpoint = HelpDeskProcess.InitiationForm

    The process name is HelpDeskProcess and the endpoint name is initForm

    But when I type this URL in the browser it opens the workspace but it shows an error "'endpoint Invalid Id". "

    Any suggestions?

    Nith

    Sorry, I meant check the TaskManager endpoint point :-) Endpoint Management

    I don't check with IE8. However, IE 6 works for me. Can you try to lower the security settings of the browser or may be trying to add this : http://server: port in your list of trusted sites and see if that makes a diff. I know that IE8 has a lot of increased security constraints.

Maybe you are looking for

  • CP assert error HP slate 6

    Random start Cp assert error poping up upward and disconnects from the network, restart, it appears every time. It started after the FACTORY RESET. Help, please. SLATE 6 VOICES TAB HSTNH-B19C modelANDROID VERSION 4.4.23.4.39 KERNEL VERSIONV1.01.06_21

  • HP Deskjet F2280 ALL-IN-ONE

    Hallo, habe bei meinem Drucker neue cartridges kidney. Farbe druckt correctly und wenn ich ein Schriftstuck print will be nichts geht. Erste ist noch gut und alles ist nicht zu read André line. Attached to los da konnte. Bitte um Hilfe! Danke...

  • HP6830: Failure of the print queue

    HP replaced my 6830 due to failure of the print head. New printer works proud desktop using Vista. Previuosly I could print from my laptop wireless as well, but it's time the print queue says printing, fails to print and return to errot impression. I

  • MozillaFirefox 16 works with windows xp?

    I read expert law books on how to do it, I cleaned my harddrive, and I defragmented as well

  • App CC

    When I uninstall a program, it does not get deleted.He remains in the update section.Any way to fix this? As I don't want to update.