Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
New Developer
Posts: 8
Registered: ‎08-22-2008
My Device: Not Specified

Re: HttpConnection how to?

Hello,

 

How do I "enable the network in simulator"?  I am using JDE4.1 and Simulator 7290.

Thanks.

 

Young

Developer
Posts: 141
Registered: ‎08-06-2008
My Device: Not Specified

Re: HttpConnection how to?

When you run simulator you will see the setup icon in first screen.

You just click that icon and follow the direction, and network setup part will be almost last.

 

Thanks.

Highlighted
New Developer
Posts: 8
Registered: ‎08-22-2008
My Device: Not Specified

Re: HttpConnection how to?

Duksunkim,

 

Thanks for the info.  Do you mean "Options" icon on blackberry simulator?  I went there and select "network", but I don't see how I can enable the network. 

 

Young

Developer
Posts: 141
Registered: ‎08-06-2008
My Device: Not Specified

Re: HttpConnection how to?

No, I mean on first the screen after you run the simulator, you will see 5 icons.

Setup Wizard

Messages

Call Log

Blackberry Messenger

Calendar

Applications

Select "Setup Wizard"

and you will see "Device Setup" and "Personalization" Directories, then Go to Application Permissions list under Personalization Directory.

 

 

 

 

 

New Developer
Posts: 8
Registered: ‎08-22-2008
My Device: Not Specified

Re: HttpConnection how to?

OK. I got the setup wizard from the 8120 simulator.

I tried the default access, but I still can not have the http demo successfully?  (gave the timeout error).  What did I do wrong?  Thanks much for the help.

 

Young

Developer
Posts: 141
Registered: ‎08-06-2008
My Device: Not Specified

Re: HttpConnection how to?

In my case, I select custom access and click next, and then I made all allow in the menu.

 

New Developer
Posts: 8
Registered: ‎08-22-2008
My Device: Not Specified

Re: HttpConnection how to?

Thanks Daksunkim for the info. BUt, unfortunately, I still can not make the httpdemo work.

 

Can anyone else help?  I have JDE4.3 and 8102 simulator. I am trying to run the httpdemo, but could not make it work.

I kept getting the "timeout error".   The web server that I am trying to access is actually the localhost, (I also tried other ones, but all with the same error). 

 

In the code below, it stuck at "httpConn.getResponseCode()".. and then error.  Really really appreciate if someone can help. 

 

Young

 

                StreamConnection s = null;
                try {
                    s = (StreamConnection)Connector.open(url);
                    HttpConnection httpConn = (HttpConnection)s;

                    int status = httpConn.getResponseCode();            /// here ======

 


                    if (status == HttpConnection.HTTP_OK)
                    {
                        //is this html?
                        String ctype = httpConn.getHeaderField(HEADER_CONTENTTYPE);
                        boolean htmlContent = (ctype != null && ctype.equals(CONTENTTYPE_TEXTHTML));

                        InputStream input = s.openInputStream();

                        byte[] data = new byte[256];
                        int len = 0;
                        int size = 0;
                        StringBuffer raw = new StringBuffer();
                        while ( -1 != (len = input.read(data)) )
                        {
                            raw.append(new String(data, 0, len));
                            size += len;
                        }
                       
                        raw.insert(0, "bytes received]\n");
                        raw.insert(0, size);
                        raw.insert(0, '[');
                        String content = raw.toString();
                        if ( htmlContent )
                        {
                            content = raw.toString();
                        }
                        //The long operation is the parsing above,
                        // after the parsing is complete, shutdown the status thread
                        // before setting the text (since both threads modify the content
                        // pane, we want to make sure we don't have the status thread
                        // overwriting our data)
                        //stopStatusThread();
                        //updateContent(content);
                        input.close();
                    } else {
                        //stopStatusThread();
                        Dialog.alert("response code = " + status);
                    }
                    s.close();

                } catch (IOException e) {
                    System.err.println(e.toString());
                    Dialog.alert(e.toString());
                    //stopStatusThread();
                    //updateContent(e.toString());
                }

BlackBerry Development Advisor
Posts: 15,884
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: HttpConnection how to?

Are you also running the MDS Simulator?  It is required to make socket or HTTP connections.

 

Also not that the BlackBerry does not allow connections to "localhost" or 127.0.0.1.  Instead, use your PC name or IP address.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
New Developer
Posts: 8
Registered: ‎08-22-2008
My Device: Not Specified

Re: HttpConnection how to?

Thank you much for the info.  "localhost" was the problem (as well as ";deviceside=true" which I forgot to add). 

Thanks again.

 

Young