BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 05-15-2008, 06:23 AM   #1
ahmadgee
Thumbs Must Hurt
 
Join Date: Apr 2008
Model: 7100T
PIN: N/A
Carrier: do not know
Posts: 51
Default uncaught exception

Please Login to Remove!

Hi every body,

I am trying to read the rss link. My code is working fine as I tested in other way without using thread. When I am using the following way using thread then it displayed the uncaught exception.

Thanks
Best regards,


Code:
public class UsingSax1 extends net.rim.device.api.ui.UiApplication{
    public static void main(String[] args){
        UsingSax1 instance=new UsingSax1();
        instance.enterEventDispatcher();
   }     
    public UsingSax1() {
        pushScreen(new UsingSaxScreen1());
   }
}
Code:
class UsingSaxScreen1 extends MainScreen{    
    
    UsingSaxScreen1() {
        
        setTitle("Using SAX Example");        
        Thread parseXML=new Thread(new ParseXML1(this));               
        parseXML.start();        
    }   
    
      public void updateScreen(String xmlstr){        
        add(new RichTextField(xmlstr));        
    }    
}
Code:
class ParseXML1 implements Runnable{
    
    UsingSaxScreen1 screen;        
    ParseXML1(UsingSaxScreen1 screen) {
        this.screen=screen;
    }
    public void run(){
               String URL = "http://www.andreasstorm.de/index.php?id=314&type=100";        
        String xmlString="";
        DataInputStream dataInputStream=null;        
        HttpConnection connection=null;        
        try{
            StringBuffer sbuffer = new StringBuffer();
            sbuffer.append(URL);

            connection = (HttpConnection)Connector.open(sbuffer.toString());            
            dataInputStream=new DataInputStream(connection.openInputStream());
            
            int ch;
            while((ch=dataInputStream.read())!=-1){
                xmlString=xmlString+(char)ch;
            }
                        
            
        }
        catch(IOException ex){
            ex.printStackTrace();
        }
        this.screen.updateScreen(xmlString);
    }
}

Last edited by ahmadgee; 05-15-2008 at 06:25 AM..
Offline  
Old 05-15-2008, 06:43 AM   #2
jfisher
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Default

most likely you're trying to update the display from a background process and this is causing the exception, you can wrap the action like so:

public void updateScreen(String xmlstr){
UiApplication.getUiApplication().invokeLater(new Runnable() {

public void run() {
add(new RichTextField(xmlstr));
}
});
}
__________________
new job doesn't allow a public profile - please do not contact this user with questions, you will not get a response. good luck!

Last edited by jfisher; 05-15-2008 at 07:17 AM..
Offline  
Old 05-15-2008, 07:05 AM   #3
ahmadgee
Thumbs Must Hurt
 
Join Date: Apr 2008
Model: 7100T
PIN: N/A
Carrier: do not know
Posts: 51
Default

Quote:
Originally Posted by jfisher View Post
most you're trying to update the display from a background process and this is causing the exception, you can wrap the action like so:

public void updateScreen(String xmlstr){
UiApplication.getUiApplication().invokeLater(new Runnable() {

public void run() {
add(new RichTextField(xmlstr));
}
});
}
Bundle of thanks and best regards for your kind help.
Can you give me suggestion that how can I capture the value of xml tags.
I have already in java using SAX simply but in blackberry there is different environment as I spent one day on the previous problem and you solved it in few seconds. Just please give me tips

thanks again
Offline  
Old 05-15-2008, 09:47 AM   #4
simon.hain
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Default

Code:
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();			
sp.parse(in, new XMLHandler());
with XMLHandler extending DefaultHandler.
__________________
java developer, Devinto, hamburg/germany
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


1PC × PR ELECTRONIC 2211 ANALOG CALCULATOR PR2211EC2A2 Ser.No. 885175 picture

1PC × PR ELECTRONIC 2211 ANALOG CALCULATOR PR2211EC2A2 Ser.No. 885175

$85.00



Columbus Instruments BP-2 Veterinary Automatic Blood Pressure Monitor picture

Columbus Instruments BP-2 Veterinary Automatic Blood Pressure Monitor

$199.94



Schneider PLC TWIDO TM2AMM6HT ANALOGUE I/O MODULE 20mA 24VDC Missing Terminal picture

Schneider PLC TWIDO TM2AMM6HT ANALOGUE I/O MODULE 20mA 24VDC Missing Terminal

$156.00



SCHNEIDER Twido TWDAMI2HT Analog 2 in 0-10v, 4-20ma Module PLC Modicon picture

SCHNEIDER Twido TWDAMI2HT Analog 2 in 0-10v, 4-20ma Module PLC Modicon

$119.99



USED Foxboro 556-9-30 Pneumatic Analog Computer St.C 3-15 PSI picture

USED Foxboro 556-9-30 Pneumatic Analog Computer St.C 3-15 PSI

$125.00



SCHNEIDER Twido TW2AMI2HT Analog 2 in 0-10v, 4-20ma Module PLC Modicon picture

SCHNEIDER Twido TW2AMI2HT Analog 2 in 0-10v, 4-20ma Module PLC Modicon

$119.99







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.