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

Reply
Developer
javame_black
Posts: 115
Registered: ‎10-04-2008
My Device: Not Specified
Accepted Solution

Progress Dialog till getting data from http connection ?

Hi,

 

Can someone help me with Progress Dialog till I get the data from Http Connection?

 

I have tried to use Status.show but how will I dismiss that once I have the data. Once I have the data I want to update UI. I think it should be the combination of Thread and UiApplication.getApplication.invokelater, but if someone can guide me in the right direction then it will be of great help.

 

 

 

Regards

Sunil

Regards
Sunil
Developer
YamilBracho
Posts: 713
Registered: ‎05-31-2010
My Device: 8520

Re: Progress Dialog till getting data from http connection ?

Developer
javame_black
Posts: 115
Registered: ‎10-04-2008
My Device: Not Specified

Re: Progress Dialog till getting data from http connection ?

[ Edited ]

Hi,

 

Thanks for pointing me to that tutorial. Why is the call like runThis.run() method. start() method of thread should be called and not directly its run() method in PleaseWaitPopUpScreen.

 

Can anyone explain me this? Its a bit confusing so any clarification will be of great help.

 

 

 

Regards
Sunil
Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Progress Dialog till getting data from http connection ?

As it says in the referenced article

"applications are not allowed to block the Event Thread".

 

You might find this useful:

 

http://supportforums.blackberry.com/t5/Java-Development/What-is-the-Event-Thread/ta-p/446865

Developer
javame_black
Posts: 115
Registered: ‎10-04-2008
My Device: Not Specified

Re: Progress Dialog till getting data from http connection ?

Hi,

 

Thanks for pointing to that video, but I understand what is Event Thread.

 

I wanted to know why the meaning of runThis.run() being called in  "PleaseWaitPopupScreen". There's no meaning of implementing Runnable then if we are directly calling its run() method rather than starting thread with start() method. And I think there's no need for implementing Runnable in GetURL since the popup is displayed in another thread and then we call the URL and then popup is removed.

 

Anyways that tutorial helped in solving my problem.

 

Thanks anyways

Regards
Sunil
Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Progress Dialog till getting data from http connection ?

What is GetURL?

 

This statement is not correct:

"There's no meaning of implementing Runnable then if we are directly calling its run() method"

 

I recommend that you review the API and looks for things that implement Runnable. 

 

Classes implement Runnable, so that the class can be used in other processing and that processing knows it can execute the supplied classes run method.  In the KB article, the Runnable is passed in to showScreenAndWait() and a separate Thread is created in that processing.  Since the showScreenAndWait() processing creates a separate Thread, it does not need to be passed in a complete Thread, it only needs to know how to run the code, so Runnable is perfect.

 

You could pass in to showScreenAndWait() a Thread, a MenuItem, a TimerTask, or anything else that implements Runnable.

 

The same concept (passing a Runnable) is used with the standard

UiApplication.getUiApplication().invokeAndWait(...);

processing.

 

Note also this statement is not 100% accurate::

"we call the URL"

 

It is the Thread created by showScreenAndWait() that invokes the Runnable.  I think by 'we' in the above you meant your own processing.

 

Hope that clears up the mystery.