BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 12-07-2007, 01:57 PM   #1
vsriram
New Member
 
Join Date: May 2007
Model: 7100
PIN: N/A
Carrier: Airtel
Posts: 12
Default pushScreen on thread closing

Please Login to Remove!

Hi all,
My application runs a thread to make an HTTP connection and fetch data. I want to push next screen on the termination of this thread indicating that the data has been downloaded. How can I do this?
I tried doing pushScreen in the onClose() method of the thread, but nothing happened. On debugging, I found, the application crashes with UncaughtException with no details. Please let me know where am I going wrong.

Thanks and regards,
V.Sriram
Offline  
Old 12-08-2007, 01:46 AM   #2
richard.puckett
Talking BlackBerry Encyclopedia
 
richard.puckett's Avatar
 
Join Date: Oct 2007
Location: Seattle, WA
Model: 9020
PIN: N/A
Carrier: T-Mobile
Posts: 212
Default

What do you mean by "the onClose() method of the thread"?

You really should look at some kind of publish/subscribe (Observer) architecture for this kind of stuff; you don't want to bind up all your code so it can never be reused.

For now though, try something like:

Application.getApplication().invokeLater(new Runnable() {
public void run() {
UiApplication.getUiApplication.pushScreen(new MyScreen());
}
});
Offline  
Old 12-13-2007, 02:15 PM   #3
Mark Rejhon
Retired BBF Moderator
 
Mark Rejhon's Avatar
 
Join Date: Aug 2004
Location: Ottawa, Ontario, Canada
Model: Bold
Carrier: Rogers
Posts: 4,870
Default

richard.puckett is right.

This is a better coding architecture: push the screen; when it closes, have the original class that pushed the screen display the final screen.

This is an okay coding architecture (better than what you do), push the confirm screen then immediately push the loading screen. There will be no time for the confirm screen to repaint itself. Once the loading screen closes, the confirm screen shows. (This doesn't show error messages, etc, but at least it's much more modular and easier to convert to an even better coding architecture)
___

Other comments about having two screens communicate with each other:
There are many ways of signalling a previous screen of a task completion, such as a callback, a semaphore, etc. Some even passing the screen as a variable to the new screen, so that the new screen can call a function within the original screen. An example is pass the original screen to the loading screen as a "Screen origScreen" parameter, then check that Screen is "if (origScreen instanceof MySpecificScreenClass)" and if it is, then you can safely call your own custom functions in your original MySpecificClass screen, through a construct similiar to ((MySpecificClass) origScreen).myOwnFinishedLoadingFunc( ) .... (you may have to cast to a variable first, before calling the method) It works. Be forewarned of potential caveats of any approach you do, and try to program as generically as possible that your situation allows. It's a very powerful BlackBerry programming trick: It's very tempting to do this trick to do neat things such as modify the textfields of a previous screen while the next screen is still displayed (Not good programming practice, as this is only appropriate to do, if the two screens are intricately related to each other and are never used by itself anywhere else, and that other programming techniques may be more difficult. You'd need a very good reason to do things this way - I prefer doing a callback returning a populated object and let the previous screen populate fields on its own, it's a lot more generic/blackbox this way -- i.e. like a 411 popup lookup screen that populates fields in the previous screen)
__________________
Thanks,
Mark Rejhon
Author of XMPP extension XEP-0301:
www.xmpp.org/extensions/xep-0301.html - specification
www.realjabber.org - open source

Last edited by Mark Rejhon; 12-13-2007 at 02:26 PM..
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


Good Chimera Dongle for All Modules Samsung HTC BLACKBERRY NOKIA LG HUAWEI picture

Good Chimera Dongle for All Modules Samsung HTC BLACKBERRY NOKIA LG HUAWEI

$307.22



Blackberry Advertising Banner Vinyl Mesh Sign Fruit Vegetable Berry Farm Fresh picture

Blackberry Advertising Banner Vinyl Mesh Sign Fruit Vegetable Berry Farm Fresh

$219.95



Nice Vintage Working RIM Blackberry 857, with Cradle, Collector's Item R857D-2-5 picture

Nice Vintage Working RIM Blackberry 857, with Cradle, Collector's Item R857D-2-5

$124.95



Hypothermias BLACKBERRY  🍧 Snow Cone machine Shaved Ice Flavor Syrup GALLON picture

Hypothermias BLACKBERRY 🍧 Snow Cone machine Shaved Ice Flavor Syrup GALLON

$26.96



BLACKBERRY MEAD Advertising Vinyl Banner Flag Sign Many Sizes MEDIEVAL picture

BLACKBERRY MEAD Advertising Vinyl Banner Flag Sign Many Sizes MEDIEVAL

$125.58



Cutter & Buck Genuine Leather Tri-Fold Portfolio “Blackberry Boot Camp 2010” picture

Cutter & Buck Genuine Leather Tri-Fold Portfolio “Blackberry Boot Camp 2010”

$19.99







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