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


50-TON HYDRAULIC RAM JACK porta power type cylinder lifting jacks rams picture

50-TON HYDRAULIC RAM JACK porta power type cylinder lifting jacks rams

$118.74



100 Ton Hydraulic Cylinder Jack 200cc Stroke Ram Low Profile Flat Lift Cylinder picture

100 Ton Hydraulic Cylinder Jack 200cc Stroke Ram Low Profile Flat Lift Cylinder

$124.27



Kinetic Water Ram Model E by Hydraulic MFG CO USA NO Case picture

Kinetic Water Ram Model E by Hydraulic MFG CO USA NO Case

$99.95



50 Ton Hydraulic Cylinder Jack Solid Ram 150mm/6 inch Stroke Single Acting New picture

50 Ton Hydraulic Cylinder Jack Solid Ram 150mm/6 inch Stroke Single Acting New

$149.86



 20T Hydraulic Cylinder Jack Mini Hydraulic Ram Low Profile Lifting Cylinder NEW picture

20T Hydraulic Cylinder Jack Mini Hydraulic Ram Low Profile Lifting Cylinder NEW

$88.35



50 Ton Hydraulic Cylinder Jack Solid Ram 150mm/6 inch Stroke Single Acting New picture

50 Ton Hydraulic Cylinder Jack Solid Ram 150mm/6 inch Stroke Single Acting New

$149.86







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