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

Reply
Regular Contributor
jssantosh84
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();}
    }

Please use plain text.
Regular Contributor
jssantosh84
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.

Please use plain text.
Administrator
MSohm
Posts: 14,314
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
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.
Found a bug? Report it using Issue Tracker
Please use plain text.
Regular Contributor
jssantosh84
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();}
    }

Please use plain text.
Administrator
MSohm
Posts: 14,314
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
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.
Found a bug? Report it using Issue Tracker
Please use plain text.
Regular Contributor
jssantosh84
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

Please use plain text.