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
Regular Contributor
Posts: 94
Registered: ‎05-29-2010
My Device: 9000 bold
My Carrier: asfas

problem creating in eclipse with JDE 5.0

hi all

I am trying to create a thread inside which i am try to make an http connection. But the flow is not going inside the thread. Can Anybody find why the flow is not going inside the run mehtod in the following code.

 

 

public class GPRSChanlInf implements Runnable {

 

public static Thread thread = null;

 public String getResponse(String url_final) {

         thread = new Thread(this);
            thread.start();
            Thread.sleep(20);

         }

 

 public void run() {
        InputStream is = null;
        OutputStream os = null;
        HttpConnection conn = null;

        try {

                conn = (HttpConnection) Connector.open(url_final, Connector.READ_WRITE, true);


              }

            catch(Exception e) { e.printStackTrace();}
    }

Regular Contributor
Posts: 94
Registered: ‎05-29-2010
My Device: 9000 bold
My Carrier: asfas

Re: problem creating thread in eclipse with JDE 5.0

I am getting a runtime Exceptions and a dialog saying pushModalScreen called by a non event thread.

Can anybody figure out what the the mistake.

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

Re: problem creating thread in eclipse with JDE 5.0

It looks like something within your code is triggering a dialog screen, which can't be displayed.

 

From where are you calling your thread?  What line of code is triggering the exception?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Regular Contributor
Posts: 94
Registered: ‎05-29-2010
My Device: 9000 bold
My Carrier: asfas

Re: problem creating thread in eclipse with JDE 5.0

yes. But after removing the dialog also it is not working on the device. The code is working perfectly fine on the simulator. But the execution is not going into the run method

 

public class GPRSChanlInf implements Runnable {

 

public static Thread thread = null;

 public String getResponse(String url_final) {

         thread = new Thread(this);
            thread.start();
            Thread.sleep(20);

         }

 

 public void run() {
        InputStream is = null;
        OutputStream os = null;
        HttpConnection conn = null;

        try {

               // the flow is not coming here on the device

                conn = (HttpConnection) Connector.open(url_final, Connector.READ_WRITE, true);


              }

            catch(Exception e) { e.printStackTrace();}
    }

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

Re: problem creating thread in eclipse with JDE 5.0

What does getResponse do?  What line is it failing on?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Regular Contributor
Posts: 94
Registered: ‎05-29-2010
My Device: 9000 bold
My Carrier: asfas

Re: problem creating thread in eclipse with JDE 5.0

getResponse returns the Response String read from the inputStream(called on HttpConnection). The code runs fine till    thread.start(); in the code