BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/)
-   Developer Forum (http://www.blackberryforums.com/developer-forum/)
-   -   Problem with HttpConnection read png image (server 64bit) (http://www.blackberryforums.com/developer-forum/218174-problem-httpconnection-read-png-image-server-64bit.html)

pinotiamo 01-28-2010 11:41 PM

Problem with HttpConnection read png image (server 64bit)
 
Code:

                  String url = "star.png"
                  // place server 64bit, star.png(128,128)
                  HttpConnection str = (HttpConnection) Connector.open(url);
                  byte[] baResult = null;
                  input = str.openInputStream();
                  DataBuffer db = new DataBuffer();
                  int len = 0;
                  byte[] baChunk = new byte[1024];
                  int size = 0;
                  while ( -1 != (len = input.read(baChunk)) )
                  {
                        db.write(baChunk, 0, len);
                        size += len;
                  }
                  baResult = db.toArray();
                  mapimages = Bitmap.createBitmapFromBytes(baResult,0,size,1);
....

public void paint(Graphics g)
{
    g.drawBitmap(0,0,128,128,mapimages,0,0);
}

I test on simulator + MDS is OK
but on real device image is not display

When I place star.png file on server 32 bit is OK, image is display.

please help me?

Dougsg38p 01-29-2010 12:18 PM

Probably an HTTP connection issue.

Simulator + MDS emulates a BES environment. Is the test device on BES?

If not, then you need to provide connection parameters to your URL, specifiying how you are to connect.

pinotiamo 01-31-2010 09:10 PM

My ConnectionString is below:
Code:

    public String getConnectionString()
    {
   
        String st = "";
        if ( ( RadioInfo.getActiveWAFs() & RadioInfo.WAF_WLAN ) != 0 )
        {
            if(CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_CARRIER,RadioInfo.WAF_WLAN, false))
                st = ";deviceside=true;interface=wifi";
        }
        else
        {
            //A carrier is providing us with the data service
            if(RadioInfo.getCurrentNetworkName() == null) // not wifi
                return st;
            if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_CARRIER) == CoverageInfo.COVERAGE_CARRIER)
            {
                    // blackberry internet service
                ServiceRecord rec = getBIBSRecord();
                if (rec == null)//couldn't find the right record
                            //st = ";deviceside=true";// let the phone try to do the work
                            st = "";// let the phone try to do the work
                    else//found the record, get the id
                            st = ";deviceside=false;connectionUID=" + rec.getUid()
                                        + ";ConnectionType=mds-public";
            }
            else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS)
                st = ";deviceside=false";// use the clients blackberry enterprise server
            else
                st = "";
        }
        return st;
    }

url = "h t tp//abc.com/star.png" + getConnectionString();


Dougsg38p 02-01-2010 08:22 AM

In your first code snippet, I don't see where you are checking the HTTP response code. You could be successfully reaching the server but getting an error code, like 401 or 500.

Also, do you know which of the connections you are using in this failure case?


All times are GMT -5. The time now is 04:08 AM.

Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.