How to analyze the image url in json?

Hello

I get the response from the server and crawled through json. And display it in the field

Like name1 as:

try {}
labelField1.setText (jsonObject2.get("name1").toString ());
}

catch (JSONException e)

{
System.out.println ("JSONException Description");
}

Similarly, I want to make the image. How to analyze the url of the image and display it in the BitmapField?

You must create a separate thread to extract the bytes of the image of the URL you have.

You can use the following code to get the image to the server.

public EncodedImage getImageBytesFromURL(String url){
        ConnectionFactory connFactory = null;
        ConnectionDescriptor connDescriptor = null;
        HttpConnection httpConn = null;
        InputStream inputStream = null;
        byte[] response = null;
        try {
            connFactory = new ConnectionFactory();
            connFactory.setConnectionTimeout(10*1000);
            connFactory.setAttemptsLimit(1);
            connDescriptor = connFactory.getConnection(url;interface=wifi);
            if (connDescriptor != null) {
                httpConn = (HttpConnection) connDescriptor.getConnection();
                inputStream = httpConn.openInputStream();
                int responseCode = httpConn.getResponseCode();
                if(responseCode == HttpConnection.HTTP_OK){
                    response = readStream(inputStream);
                }
            }
        }catch (IOException e) {

        }finally {
            try {
                inputStream.close();
                httpConn.close();
                inputStream = null;
                httpConn = null;
                connDescriptor = null;
                connFactory = null;
            } catch (Exception e) {

            }
        }
        EncodedImage encodedImage = null;
        if(response != null){
            encodedImage = EncodedImage.createEncodedImage(response, 0, response.length);
        }
        return encodedImage;
    }

Remember that this method should be in a background thread. Otherwise, your user interface crashes. The encodedImage that returns the method above can be easily converted to bitmap and set in your bitmapfield.

Tags: BlackBerry Developers

Similar Questions

  • How to analyze the Protocol URL using REGEXP or a substring

    Hi all

    I'm analyzing a URL (http or https) Protocol, but a few problems. Thanks in advance for your help.

    SELECT REGEXP_REPLACE('http://example.com', 'The correct expression') FROM DUAL;
    

    I need the expression work for http or https.

    Thank you

    with

    data in the form of

    (select 'http://example.com' expression of union double all the)

    Select "https://example.com" expression of all the double union

    Select "www://example.com" expression of double

    )

    Select expression, substr (expression, 1, instr(expression,':') - 1) Protocol

    from the data

    EXPRESSION PROTOCOL
    http://example.com http
    https://example.com HTTPS
    www://example.com www

    Concerning

    Etbin

  • How to disable the image previews

    In the windows client there is an option to disable the image previews with

    Tools-> Options-> settings IM-> Show advanced options. Uncheck the option: "show images in conversations".

    In the client Mac there isn't this option. How to disable the image previews in a Mac client?

    OK, found the solution in another thread here: http://community.skype.com/t5/Mac/YouTube-thumbnails-amp-link-previews-Why-don ' t-I-see-them/m-p/39692...

    Menu bar-> display-> display Images-> uncheck

  • How to change the Image the Image (8 bit) (32 bit)?

    Dear all,

    I have a question about VISION.

    An Image from IMAQ USB Grab Acquire.vi is 32-bit, even if the IMAQ Creat.vi has the type U8 value.
    But the more IMAQ vi (for example IMAQ get LCD ROI.vi) can only deal with 8-bit Image.
    How to change the Image from 32-bit to 8-bit Image?
    Thank you!

    Hugo

    Hi Hugo,.

    You use a color camera? coz usually 32 bit for a color image.

    If so, you can try the unique color Pane.vi extract to extract its Luminance component. It then becomes an 8-bit grayscale image.

    Zheng OR AE

  • How to rotate the image in movie maker a few degrees to get it exactly horizontal

    If my camera was slightly off level during recording, how I rotate the image a few degrees in Movie Maker to get this level

    I found a copy of 1.9.2.

    Excellent

    Wayne

  • How to see the Images in the project of addiction?

    Hi all

    I have two projects, one dependent on the other, I did a project in the project library, and the other as a CLDC Application. I have some images stored in the library project, and I want to access that images of the CLDC Application. I don't know how to access the images by hint which way. Any body know the solution please help me.

    Thank you and best regards,

    Rajapandian.K

    I had to help someone with something similar to this:

    http://supportforums.BlackBerry.com/T5/Java-development/how-can-I-place-resources-in-a-separate-cod/...

    You can add an extra function so that she gets the EncodedImage and returns.

    In fact, I just realized that EncodedImage.getEncodedImageResource has support for the specification of the module that contains the resource.

  • How to rotate the image only once

    Hai, I am very new in the development of blackberry applications. I need an image that need to be done rotate 360 degrees once only. I see so many references here and I know that there is a thread that discuss it, but I can't find the right one.

    Thanks in advance.

    You asked a single rotation - "how to rotate the image only once.

    There is no standard API that provides a rotating image permanently using standard features of BlackBerry.

    The usual way to display animations is demonstrated in this article.

    http://supportforums.BlackBerry.com/T5/Java-development/display-an-animated-GIF/Ta-p/445014

    If you can prepare your animation and package with your application, it will be much easier and more effective. Do you know what pictures you're going to turn?

  • How to display the image in the center of the imageview window?

    How to display the image in the center of the imageview window, if the image is smaller than the window...

    Page {
        Container {
            layout: DockLayout{}
            verticalAlignment: VerticalAlignment.Fill
            horizontalAlignment: HorizontalAlignment.Fill
            ImageView {
                imageSource: "asset:///images/image.png"
                verticalAlignment: VerticalAlignment.Center
                horizontalAlignment: HorizontalAlignment.Center
            }
        }
    }
    
  • How to change the image field captures screenshots automatically from BMP to JPEG

    How to change the image field captures screenshots automatically from BMP to JPEG

    I want to say, when I tap on the screenshot on my keyboard and paste this image in microsoft photo editor or picasa 3.0 areas of the bitmap .bmp. instead of asking the witch I´d field prefer.
    So, I open that image on the brush to convert it to. JPEG.
    It's hick very!
    is it possible to easily me this step and save or paste pictures in JPEG on my files automatically?

    Hello

    I saw that article when I was looking for one that I posted...

    I understand your problem, and the answer is that, to the best of my knowledge... NO..

    Windows records the capture in memory as bitmap, along with, even if you can paste it directly into a folder, it would be in the form of bitmap...

    The best I could find is to use the suggestion in the link I've included which refers to the

    Windows Key + PrintScreen to automatically record is in PNG format in your pictures folder...

    The only way to do what you want is with a 3rd party capture program that can be configured to save in a directory as a specific file type...

    Personally, I use a program called print screen Deluxe for this... it is a purchased program...

    I'm sure you could find something free to do what you need...

    You may need to use a different key for print screen, but the software can allow you to reprogram the PrntScrn key...

  • How to put the image inside the image of the desktop

    Hi team,

    I'm on MAC and I wonder if you could please help by telling step-by-step how to insert the image inside the desktop image in Photoshop. Thank you much in advance.

    Basically what you are looking for, it's transform freely. I hope this video helps.

  • How to check the image source for the image which is losted?

    Hello world

    How to check the image source for the image which is losted?

    If the image source already exists, I can read the PlaceItem.file.fsName.

    But if remove the image of the source, read the PlaceItem.file.fsName will report the error: there is no file associated with this element

    Thank you

    If (app.documents.length > 0) {}

    var sourceDoc = app.activeDocument;

    sourceName = sourceDoc.name var;

    artItem =]

    for (i = 0; i < sourceDoc.pageItems.length; i ++) {}

    artItem [i] = sourceDoc.pageItems [i];

    If (.) TypeName artItem [i] == 'PlacedItem') {}

    If (.imageColorSpace [i] artItem == undefined) {}

    Alert ("the file is the link, but I don't know whether or not the source image is losted");

    }

    }

    }

    }

    Use try/catch to catch the error

    if (app.documents.length > 0) {
        var sourceDoc = app.activeDocument;
        var sourceName = sourceDoc.name;
        artItem = []
        for (i = 0; i < sourceDoc.pageItems.length; i++) {
            artItem[i] = sourceDoc.pageItems[i];
            if (artItem[i].typename == 'PlacedItem') {
                if (artItem[i].imageColorSpace == undefined) {
                    try {
                        var fname = artItem[i].file.name;
                        alert("file name: " + fname);
                    }
                    catch (e) {
                        alert("The file is linking ,but source image is lost");
                    }
                }
            }
        }
    }
    
  • How to change the image on the layer of the photo?

    How to change the image on the layer of the photo? I accidentally chose the wrong design and I'm not able to delete/modify it. Already, I had little work, so the change in office had to happen sooner.

    Sara

    To change the image in the photo layer

    1. Select the layer of the photo in layers;

    2. click on the button to learn more.

    3. delete the current photo;

    4. the layer is reset with no picture

  • How to rotate the image in the muse of adobe?

    Hello.. I would like to know how to rotate the image in the muse of adobe?

    Use this free widget:

    https://creative.Adobe.com/addons/products/2117#.VXla5jNcOeV

  • How to get the friendly URL to the web sites of the centre

    Anyone know where I can find good instructions on how to produce the friendly URL to the web sites of the centre

    Hi Ahmed.

    If you are running version 7.6 or 11gR1BP1 or earlier, the GST Site Foundation is a good option for you.    The GSF website is here:

    http://www.GST-Foundation.org/

    and I have recently written a howto for vanity URL using the FMA here:

    http://www.function1.com/2012/11/how-to-use-vanity-URLs-in-the-GSF-with-WebCenter-sites/

    Please let me know if you have any questions!

    Sincerely,

    Tony Field

    Function1

  • I created an animated banner 468 x 60 in edge animate. How to save the image hosted on my desk? (not in HTML)

    I created an animated banner 468 x 60 in edge animate. How to save the image hosted on my desk? (not in HTML)

    Hello

    This feature is not available in Adobe Edge animate. You cannot export as image of the animate edge.

    Publish here describe the options available on board

    M lively help | Publish your content

    Kind regards

    Devendra

Maybe you are looking for

  • Why is there no option 'print Fames' in my printing box. Using Firefox 32.0.3

    Why my printing box does not display the options Print framework? They are not at all. I use Firefox 32.0.3 which I believe is the latest version.

  • Restoring factory MacBook

    I was setting up new mi 1.3 Ghz macbook for the first time and it froze before the end. I stopped it and now when you try to restart, it only shows a circle with a line through it. Could someone please offer some advice? Thank you very much Alberto

  • HP all-in-one touch: while a touchscreen video card

    Can I put th video card because he did not have enough memeory to run the games I want to play?  Batman Arkum city says im running 1904 497 so that the screen stops and starts and shutters

  • Possible upgrade for my card WIFI (AR9285) (AR9280) Dv7-3065dx

    DV7-3065dx Windows 7 Edition Home Premium x 64 Hello, I am looking to update my map of current wireless (AR9285) for the ATHEROS AR9280 network so I can use my signal of 5 GHz of routers. It seems that when you shop, the AR9280 and AR5BHB92-H model n

  • BlackBerry Smartphones, wifi and mobile network Q

    If I turn on my wifi at home & sign in, & at the same time, let Mobile network on... fresh data which of them will be run out of?  The Mobile network will win or share or just use wifi? Also I was wondering because I wonder if light work wifi when I'