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
Posts: 40
Registered: ‎08-13-2009
My Device: Not Specified

Handling more than one call in PhoneListener

[ Edited ]

Hello All!

my PhoneListener pops up a screen to save the call details, when the call gets disconnected. the screen automatically fills some fields(call duration, caller's phone number). this works fine if there is only one call in process. the problem i face is when there is another call comes in picture. e.g. user is on a call, CallA, and another call, CallB, arrives, then

case 1: user doesn't attend the CallB and call gets disconnected. now as soon as the CallB disconnects, the screen pops up and shows the call details as phone number of CallA and duration. this screen should not come up as CallA is still active. there can be other cases also like if user attends CallB and disconnects after, lets say, 30 seconds. CallA is still active and conference call and so on.......

i know the problem is that there is only one instance created for the call, so the CallA and CallB both are represented by that one instance. now i want to know that how should i manage more than one phone calls in one phone listener. should it be done by creating an array of PhoneCall objects or should i use thread in some way or is there any other option available.

following is the code for the PhoneListener.

public class CustomPhoneListener extends AbstractPhoneListener{

private Main theApp;

private Date startTime;

private boolean callConnected = false;

private PhoneCall call = null;

public CustomPhoneListener(Main theApp){

this.theApp=theApp; startTime = null;

}

public void callConnected(int callId) {

//Dialog.alert("Call Connected");

callConnected = true;

startTime = new java.util.Date();

call = Phone.getCall(callId);

if(theApp.isForeground()){

theApp.requestBackground();

}

}

public void callDisconnected(int callId){

theApp.requestForeground();

theApp.invokeLater(new Runnable(){

public void run(){

if (callConnected){

// String phoneNbr = call.getDisplayPhoneNumber();

Screen screen = new ConfirmTagScreen(call, null, startTime);

theApp.pushScreen(screen);

screen.setFocus();

}else{

theApp.requestBackground();

}

} else{

theApp.requestBackground();

}

callConnected = false; }});

}

}

------------------------------------------------------------------------------
The truth is not for all men, but only for those who seek it :smileyhappy:
------------------------------------------------------------------------------
Thanx and Regards
Naveen Kumar
Developer
Posts: 74
Registered: ‎01-03-2010
My Device: Not Specified

Re: Handling more than one call in PhoneListener

probably your custom listenerworks with callA while default listener is handling callB

Developer
Posts: 40
Registered: ‎08-13-2009
My Device: Not Specified

Re: Handling more than one call in PhoneListener

are there two different Listenrs???? what i think is that the listener is able to deal wth only one CALL. my questions is wat changes do i need to make, in my PhoneListener, to deal wth more than one call? 

------------------------------------------------------------------------------
The truth is not for all men, but only for those who seek it :smileyhappy:
------------------------------------------------------------------------------
Thanx and Regards
Naveen Kumar
Developer
Posts: 26
Registered: ‎02-02-2010
My Device: 9630
My Carrier: Verizon

Re: Handling more than one call in PhoneListener

Have you tried keeping track of the callid? You may want to create a structure (object) to hold the call information and update the structure from the callbacks. This way you can handle multiple active calls - add a value to determine if the call is over, etc. Based on the duration, and possibly the sort, you can figure out which dialog to popup when. If it were me, I would likely create a separate task to handle the dialog and just use the listener callbacks to update the structure.

 

Rick

 

Developer
Posts: 40
Registered: ‎08-13-2009
My Device: Not Specified

Re: Handling more than one call in PhoneListener

[ Edited ]

Thank you for the reply Rick,

                                            now i m going to create a class, which holds the information of call(duration, starttime etc). will create an array of this class to keep more than one call. i think this is what you also suggested.

 

one more question i have. here in India we can have maximum of 6 calls in conference (facility provided by Service Provider). i m not sure if this is the standard limit followed accross the globe? please tell me at a given point of time how many calls can be on the conference in your country?

------------------------------------------------------------------------------
The truth is not for all men, but only for those who seek it :smileyhappy:
------------------------------------------------------------------------------
Thanx and Regards
Naveen Kumar
Developer
Posts: 26
Registered: ‎02-02-2010
My Device: 9630
My Carrier: Verizon

Re: Handling more than one call in PhoneListener

Unfortunately I haven't tried but info I found searching around on Verizon, etc. sounds like 6 is an appropriate limit here. I'm curious why the number would matter. Perhaps you should create a Hashtable to hold the call data stored by the callid - you can always enumerate through them if you need to and this way there won't be a limit to any particular number.

 

Rick

 

If you like my answer, kudos and confirmation are always welcome.

Developer
Posts: 40
Registered: ‎08-13-2009
My Device: Not Specified

Re: Handling more than one call in PhoneListener

Thanx again Rick!

                            i have done some work around to solve one of my main issues, (when user is on CallA and CallB arrives and disconnected without getting any treatment). unfortunately or fortunately, i am shifted to another project for some time now. so will work on the conference problem after some time.

and thanx to you, this HashTable seems, the exact thing i wanted for the conference and some other related problems.......... i can see the problem getting solved.................

------------------------------------------------------------------------------
The truth is not for all men, but only for those who seek it :smileyhappy:
------------------------------------------------------------------------------
Thanx and Regards
Naveen Kumar