×

Discussion Board

Results 1 to 2 of 2

Thread: thread problem

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    2

    thread problem

    Hello,

    I have a MIDLET Runnable:


    Code:
     public void run()
        {
            try
                {
                     cont33 = Conn("http://finance.yahoo.com/");
                }
            catch (Exception exc)
                {
                    exc.printStackTrace();
                }
    }
    Code:
    String Cont(String url) throws IOException {
             HttpConnection c = null;
             InputStream is = null;
             StringBuffer str = new StringBuffer();
    
             try {
                 c = (HttpConnection)Connector.open(url);
    
    
    
                 // Get the ContentType
                 String type = c.getType();
    
                 // Getting the InputStream will open the connection
                 // and read the HTTP headers. They are stored until
                 // requested.
                 is = c.openInputStream();
    
    
    
                 // Get the length and process the data
                 int len = (int)c.getLength();
                 int ch;
                 while ((ch = is.read()) != -1) {
                        str.append((char)ch);
                     }
    
             } finally {
                 if (is != null)
                     is.close();
                 if (c != null)
                     c.close();
    con22 = "text";
    
             }
    
    
    // Before returning, the resultant String should be parsed to get Exchange Rate
    
    String val = str.toString();
    return val;
         }

    In MIDLET i start the THREAD:
    Code:
     Thread topCont = new Thread(this);
                topCont.start();

    cont33 and con22 are global strings variable.


    The problem is that function Con returns NULL and con22 is not set
    I've tested, and before returns(return val, val is not null.

    What I should do?

    The problem it is in function or thread... Con can't comunicate with exterior..

  2. #2
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: thread problem

    Hi,
    You have to do the more work about the Java Programming Naming Convention.

    http://java.sun.com/docs/codeconv/

    The method returning the correct value,just you chnage the variable scope,in which you are assigning the string returned by that method.Try to declare the val as global.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

Similar Threads

  1. S60 5th ed emulator startup failed
    By hony in forum Symbian Tools & SDKs
    Replies: 8
    Last Post: 2009-08-11, 21:12
  2. [moved] can not install application in emulator
    By HAHAPrince in forum Symbian Tools & SDKs
    Replies: 26
    Last Post: 2009-04-02, 20:34
  3. Thread Problem on device
    By luoyingzhou in forum Symbian
    Replies: 8
    Last Post: 2007-04-23, 08:35
  4. Problem with the Nokia 6600, Bluetooth and Monty Thread
    By tenfourty in forum Mobile Java General
    Replies: 15
    Last Post: 2005-09-30, 14:15

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×