BlackBerry Forums Support Community
              

Closed Thread
 
LinkBack Thread Tools
Old 08-07-2008, 02:48 AM   #1 (permalink)
Talking BlackBerry Encyclopedia
 
arunk's Avatar
 
Join Date: Mar 2008
Model: 8310
PIN: N/A
Carrier: Airtel
Posts: 229
Post Thanks: 0
Thanked 0 Times in 0 Posts
Question How to do call back?

Please Login to Remove!

I want to read the XML contents using http connection in a new thread and once the content has been read, I want the control to comeback to the main thread and execute the statement just after the one which invoked the thread.

something like return the value...

is it possible or any alternate method is there?
Offline  
Old 08-07-2008, 08:03 AM   #2 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

i'll try to explain it a bit more simple.

you have your application A.
create an interface I. Add a method hurraTheDataAreThere(byte[] data).
Let A implement I.
Alter your connection thread to take an I as a parameter.
The interface there is to limit the access to only this one method.

In code this would look something like
Code:
//in your app
I callback = this;
new ConnectionThread(callback).start();

//in the connectionthread after the data are there
callback.hurraTheDataAreThere(data);

//in the application:
public void hurraTheDataAreThere(byte[] data){
System.out.println("hurra, the data are there! And they are "+data.length+" long");
}
in general you could also just pass the application object to your connection thread. but better to start with best practices instead of learning them later.
__________________
java developer, Devinto, hamburg/germany
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

1PC USED Samsung servo motor CSM-04BB2ANT3
$108.99
1PC USED Samsung servo motor CSM-04BB2ANT3 picture1pc used Samsung S50HW-YB02 Y board LJ41-05120A LJ92-01490A
$79.28
1pc used Samsung S50HW-YB02 Y board LJ41-05120A LJ92-01490A pictureRemote Control For Samsung ARC-2230 ARH-2214,ARH-428,ARH-430,ARH-441 Air Conditi
$8.5
Remote Control For Samsung ARC-2230 ARH-2214,ARH-428,ARH-430,ARH-441 Air Conditi picture1pc used Samsung air conditioning KFR-35GW / MCC computer board DB93-01017C
$50.28
1pc used Samsung air conditioning KFR-35GW / MCC computer board DB93-01017C picture1 x Toner Cartridge Compatible With Samsung MLT-D1082S, MLTD1082S - 1500 Pages
$25.18
1 x Toner Cartridge Compatible With Samsung MLT-D1082S, MLTD1082S - 1500 Pages picture






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