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



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


FANUC Servo Amplifier A06B-6240-H208 picture

FANUC Servo Amplifier A06B-6240-H208

$3199.00



MITSUBISHI Amplifier MR-J2S-200B MRJ2S200B AC Servo Drive New in box picture

MITSUBISHI Amplifier MR-J2S-200B MRJ2S200B AC Servo Drive New in box

$463.00



 MITSUBISHI Amplifier MITSUBISHI MR-J2S-200B MITSUBISHI MRJ2S200B AC Servo Drive picture

MITSUBISHI Amplifier MITSUBISHI MR-J2S-200B MITSUBISHI MRJ2S200B AC Servo Drive

$485.00



Used Fanuc Servo Amplifier A06B-6114-H102 picture

Used Fanuc Servo Amplifier A06B-6114-H102

$869.33



Honeywell R7849 A 1023 Ultraviolet Amplifier NEW picture

Honeywell R7849 A 1023 Ultraviolet Amplifier NEW

$171.66



IM1-22Ex-R TURCK ISOLATING SWITCHING AMPLIFIER NEW  picture

IM1-22Ex-R TURCK ISOLATING SWITCHING AMPLIFIER NEW

$154.00







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