Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8157291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:13:55+00:00 2026-06-06T17:13:55+00:00

I cannot load the image from url and play into my listfield ImageLoader class

  • 0

I cannot load the image from url and play into my listfield

ImageLoader class

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 < 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 (IOException e) {
            e.printStackTrace();
        }

        return b.toString();
    }
}

ListField class

image = new BitmapField(Util_ImageLoader.getImageFromUrl(
    "http://www.orientaldaily.com.my/images/articles/4_APRIL_BLACK_copy.jpg"),
    Field.FIELD_HCENTER | Field.FIELD_VCENTER);
row.add(image);
field = getField(3);
layoutChild(field, 100, 80);
setPositionChild(field, getPreferredWidth() - 105, 5);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T17:13:57+00:00Added an answer on June 6, 2026 at 5:13 pm

    You need to add connection extension to Your Url.

    like if wifi then “;interface=wifi”

    Example: c = (HttpConnection) Connector.open(url+";interface=wifi");
    

    Using perfect connection perameter

    c = (HttpConnection) Connector.open(url+getConnParam());
    

    code sample for getting connection extension:

    public static String getConnParam(){
            String connectionParameters = "";
            if (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED) {
            // Connected to a WiFi access point
            connectionParameters = ";interface=wifi";
            } else {
            int coverageStatus = CoverageInfo.getCoverageStatus();
            ServiceRecord record = getWAP2ServiceRecord();
            if (record != null
            && (coverageStatus & CoverageInfo.COVERAGE_DIRECT) ==
            CoverageInfo.COVERAGE_DIRECT) {
            // Have network coverage and a WAP 2.0 service book record
            connectionParameters = ";deviceside=true;ConnectionUID="
            + record.getUid();
            } else if ((coverageStatus & CoverageInfo.COVERAGE_MDS) ==
            CoverageInfo.COVERAGE_MDS) {
            // Have an MDS service book and network coverage
            connectionParameters = ";deviceside=false";
            } else if ((coverageStatus & CoverageInfo.COVERAGE_DIRECT) ==
            CoverageInfo.COVERAGE_DIRECT) {
            // Have network coverage but no WAP 2.0 service book record
            connectionParameters = ";deviceside=true";
            }
    
        }
            return connectionParameters;
        }
    

    reference urls:

    http://www.blackberry.com/developers/docs/4.6.0api/javax/microedition/io/Connector.html#http

    http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/What_Is_-_Different_ways_to_make_an_HTTP_or_socket_connection.html?nodeid=826935&vernum=0

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do you load an image from a URL and then put it into
I tried to load top3 record of table into DataGrid it shows error Cannot
Based on feedback from URL to load resources from the classpath in Java i
i use the following code to load image to a cell $(cell).css(background-image, url(+iconImage+)); As
USing UIImage, I know we can store an image from a URL. But I
This is my class in essence import mx.controls.Image; public class ImageFrameView extends Image {
I need to load an image from IsolatedStorage , and display it on an
It's possible to load an image from resources passing to R.drawable a String? I'm
I'm just wondering why I cannot load a resource with the Thread context loader
I am using System.Reflection to load a type that I cannot otherwise load during

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.