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: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900
My Carrier: developer
Accepted Solution

Problem in running networking application

Hello

 

I want to ask what is the better approach of doing network related application.Do i have to create the Custom thread for this or implements the Runnable Interface.

 

And how to start them by simply calling the .start() in case of thread or .run() in case of interface?

Highlighted
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Problem in running networking application

threads are always started by start().
you can use new Thread(){}.start() and overwrite the run function of thread for the shortest implementation.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900
My Carrier: developer

Re: Problem in running networking application

Thanks Sir for the reply

 

Sir i have to perform multiple networking task in the same buttom click.

Like if i click a button 3 webservices are called, then i have to start the 1 thread in that i will start the other two??

Developer
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900
My Carrier: developer

Re: Problem in running networking application

And 1 more problem.

When i click on a Bitmapfield. A popup screen has to be displayed.

 

SO when i click on Bitmapfield, i simply push the popup screen but it doesnot displayed.Then i add the thread and the i got the exception saying pushscreen without holding event lock.Now i am doing like this Is that ok??

 

imageField = new BitmapField(Icon,BitmapField.FOCUSABLE)
{
protected boolean navigationClick(int status, int time)
{
try
{
synchronized (UiApplication.getEventLock())
{
NewCustomDialog dialog = new NewCustomDialog("successfully ", Field.FIELD_TOP, Color.BLACK);
UiApplication.getUiApplication().pushScreen(dialog);
Thread.sleep(4000);
}

}

catch(Exception e){}

}

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Problem in running networking application

you should spend a bit of time to understand the topic of the event thread.
this should help:
http://supportforums.blackberry.com/t5/Java-Development/What-is-the-Event-Thread/ta-p/446865

in the navigationClick method you are on the event thread. no need to use a sync on the event lock (which should not be used anyhow, in most cases invokelater is better).

Thread.sleep is also called on the event thread, this pauses all processing for four seconds. That means drawing the UI and listening for user input.
never do that.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900
My Carrier: developer

Re: Problem in running networking application

Thanks Sir

Now i understood the difference.