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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 223
Registered: ‎06-08-2010
My Device: pearl8100
My Carrier: airtel

Re: In need to call UiApplication inside run() thread

Hi,

again for another different class.I am getting same error.But for first class it got corrected.

 public void run() {
 
 
                             HttpTransport  transport = new HttpTransport ("http://133.234.456.78:8080/axis2/services/LocalDiscoverdb?wsdl");
                            SoapObject myObject = new SoapObject("http://WS", "getSearchORResponse");
                              myObject.addProperty("compname", this.Company);
                           myObject.addProperty("conname",this.ContactName);
                             SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
                                envelope.bodyOut = myObject;
                           envelope.setOutputSoapObject(myObject);
                                transport.debug = true;
                                 try {
                                 transport.call("http://WS/getSearchORResponse", envelope);
                             response = envelope.getResponse();
                              System.out.println(response.toString());
                              if(response==null){
                                  Dialog.alert("Incorrect CompanyName or ContactName"); 
                                }
                                else{
                             SoapObject body = (SoapObject) envelope.bodyIn;
                             int k= body.getPropertyCount();
                             System.out.println(k);
                            if (k == 1) {
                                System.out.println(body.getProperty(0).toString());
                                   lameParser(body.getProperty(0).toString());
                                                          
         s =new Scr();
UiApplication.getUiApplication().invokeLater(new Runnable()
{  
  public void run()
    {
UiApplication.getUiApplication().pushScreen( s);
     }
})
;         
          CompanyName = new LabelField(sCompname,LabelField.FIELD_RIGHT|LabelField.USE_ALL_WIDTH){
           public void paint(Graphics g) {
                                  g.clear();
                               g.setColor(Color.BLACK);
               g.fillRect(0, 0, getWidth(), getHeight());
                g.setColor(Color.IVORY);
                                 super.paint(g);
                        }          
                      
        };       
        Font font6=fontFamily[1].getFont(FontFamily.SCALABLE_FONT, 16);
              CompanyName.setFont(font6);
             s.getMainManager().add(CompanyName);
     Name = new ExRichTextField(sName,Color.ALICEBLUE,Color.BLACK);
      s.getMainManager().add(Name);
      Designation = new ExRichTextField(sDesignation,Color.ALICEBLUE,Color.BLACK);
       s.getMainManager().add(Designation);
      Email = new ExRichTextField(semail,Color.ALICEBLUE,Color.BLACK);
      s.getMainManager().add(Email);
      Phone = new ExRichTextField(sphone,Color.ALICEBLUE,Color.BLACK);
      s.getMainManager().add(Phone);
      ReportTo = new ExRichTextField(sreport_to,Color.ALICEBLUE,Color.BLACK);
      s.getMainManager().add(ReportTo);}//}
    else{
      
          s =new Scr();
UiApplication.getUiApplication().invokeLater(new Runnable()
{  
  public void run()
    {
UiApplication.getUiApplication().pushScreen( s);
     }
})
;         
         
      
        for (int i = 0; i <5; i++) {
              lameParser(body.getProperty(i).toString());
            if(i%2==0){
               CompanyName = new LabelField(sCompname,LabelField.FIELD_RIGHT|LabelField.USE_ALL_WIDTH){
           public void paint(Graphics g) {
                                             g.clear();
                               g.setColor(Color.BLACK);
               g.fillRect(0, 0, getWidth(), getHeight());
                g.setColor(Color.IVORY);
                                            super.paint(g);
                        }          
                      
        };        
          Font font6=fontFamily[1].getFont(FontFamily.SCALABLE_FONT, 16);
              CompanyName.setFont(font6);
             s.getMainManager().add(CompanyName); 
             Name = new ExRichTextField(sName,Color.ANTIQUEWHITE,Color.BLACK);
              Font font4=fontFamily[1].getFont(FontFamily.MONO_BITMAP_FONT, 16);
              Name.setFont(font4);
      s.getMainManager().add(Name);
      Designation = new ExRichTextField(sDesignation,Color.ANTIQUEWHITE,Color.BLACK);
       Designation.setFont(font4);
       s.getMainManager().add(Designation);
      Email = new ExRichTextField(semail,Color.ANTIQUEWHITE,Color.BLACK);
      Email.setFont(font4);
      s.getMainManager().add(Email);
      Phone = new ExRichTextField(sphone,Color.ANTIQUEWHITE,Color.BLACK);
      Phone.setFont(font4);
      s.getMainManager().add(Phone);
      ReportTo = new ExRichTextField("Reports To: "+sreport_to,Color.ANTIQUEWHITE,Color.BLACK);
      ReportTo.setFont(font4);
      s.getMainManager().add(ReportTo); 
       s.getMainManager().getVerticalScroll();
       }
      else{
           CompanyName = new LabelField(sCompname,LabelField.FIELD_RIGHT|LabelField.USE_ALL_WIDTH){
           public void paint(Graphics g) {
                                             g.clear();
                               g.setColor(Color.BLACK);
               g.fillRect(0, 0, getWidth(), getHeight());
                g.setColor(Color.IVORY);
                                            super.paint(g);
                        }          
                      
        };     
          Font font6=fontFamily[1].getFont(FontFamily.SCALABLE_FONT, 16);
              CompanyName.setFont(font6);
             s.getMainManager().add(CompanyName);  
            Name = new ExRichTextField(sName,Color.ALICEBLUE,Color.BLACK);
            Font font4=fontFamily[1].getFont(FontFamily.MONO_BITMAP_FONT, 16);
              Name.setFont(font4);
      s.getMainManager().add(Name);
      Designation = new ExRichTextField(sDesignation,Color.ALICEBLUE,Color.BLACK);
       Designation.setFont(font4);
       s.getMainManager().add(Designation);
      Email = new ExRichTextField(semail,Color.ALICEBLUE,Color.BLACK);
       Email.setFont(font4);
      s.getMainManager().add(Email);
      Phone = new ExRichTextField(sphone,Color.ALICEBLUE,Color.BLACK);
        Phone.setFont(font4);
      s.getMainManager().add(Phone);
      ReportTo = new ExRichTextField("Reports To: "+sreport_to,Color.ALICEBLUE,Color.BLACK);
       ReportTo.setFont(font4);
      s.getMainManager().add(ReportTo);
       s.getMainManager().getVerticalScroll();
        }
    }
}}

 

 

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Please press the kudos button on the left side to thank the user that helped you.
Developer
Posts: 282
Registered: ‎02-25-2010
My Device: curve,bold,storm
My Carrier: Verizon,AT&T

Re: In need to call UiApplication inside run() thread

can u tell me which error u got and at what point

 

make sure whenever u do ui changes from a thread other than event thread always use invokelater

 

put all Dialog.inform inside invoke later,may be this is creatinng problem

Developer
Posts: 223
Registered: ‎06-08-2010
My Device: pearl8100
My Carrier: airtel

Re: In need to call UiApplication inside run() thread

Hi,

Here also i got illegal state change exception .while adding my datas to screen.I dont get any line number with exception for above class.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Please press the kudos button on the left side to thank the user that helped you.
Highlighted
Developer
Posts: 70
Registered: ‎01-02-2009
My Device: Not Specified

Re: In need to call UiApplication inside run() thread

 

Move all UI related code in run() method to the invokeLater() and try.

 

Go through this links, this will help you..

 

How to - Update a screen on the Main Event Thread

 

Usefull links

 

 

---------------------
Best Regards,
Kannabiran.
---------------------
Don't forget to mark your post as solved if you got answer. And give kudos.
Developer
Posts: 282
Registered: ‎02-25-2010
My Device: curve,bold,storm
My Carrier: Verizon,AT&T

Re: In need to call UiApplication inside run() thread

kanna is right

u have to put all the ui code inside the invoke later

 

i mentioned in my post  to put all ui components inside that method

Developer
Posts: 223
Registered: ‎06-08-2010
My Device: pearl8100
My Carrier: airtel

Re: In need to call UiApplication inside run() thread

Hi,

 

Thanks all it worked.Great.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Please press the kudos button on the left side to thank the user that helped you.