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
New Developer
rahul8270
Posts: 57
Registered: ‎06-02-2009
My Device: Not Specified

Re: Call Initiated event generated twice !!!!

Hi ,

 

I am also facing the same problem . Call connected method is getting called twicw when i disconnect the call and make a call after selecting number from my screen .

 

 

Regards

Rahul

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

Re: Call Initiated event generated twice !!!!

Can you tell us the environment in which you are seeing this problem, especially device/simulator model and OS, JDE/plug-in level.

New Developer
rahul8270
Posts: 57
Registered: ‎06-02-2009
My Device: Not Specified

Re: Call Initiated event generated twice !!!!

I am using JDE 4.5 /8300 .
Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Call Initiated event generated twice !!!!

Is this a real 8300 or the Sim that comes standard with 4.5?
New Developer
rahul8270
Posts: 57
Registered: ‎06-02-2009
My Device: Not Specified

Re: Call Initiated event generated twice !!!!

It is Sim that comes standard with 4.5 not real one .
New Developer
krishn2
Posts: 94
Registered: ‎03-06-2009
My Device: Not Specified

Re: Call Initiated event generated twice !!!!

R u getting the notification in callInitiated() method.Kindly put a log in this method and check.

 

I dont know the exact reason but i faced the same issue and i figured it out that if you disconnect the native call and create a call from your applicaiton, BlackBerry will create a new PhoneListener instance instance and give callbacks to both the instances. 

 

if you print the REFERENCE of PhoneListener class iside your callInitiated() method and also the call ID, you will see that PhoneListener refernce is differect in both the cases while the call ID is same.

Developer
myraddin
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: Call Initiated event generated twice !!!!

[ Edited ]

Excellent observation krishn2.

 

Cannot confirm but it definitely makes sense.

 

A workaround: Always memorize the call initiated call ID and the first thing to do inside callInitiated is to check whether the last handled initiated call id != the memorized one (if it isn't than it's a duplicate callback, just ignore it).

 

 

int fLastInitiatedCallID = -1;
public void callInitiated(final int aCallID)
{
if (fLastInitiatedCallID == aCallID)
{
// used for duplicate callInitiated callback. Just ignore it.
return;
}

// memorize the current initiated ID
fLastInitiatedCallID = aCallID;

 

// ... other code ...

}

 

 

 

That way there is no chance to do the handling twice (and is safe since there is no way to get two callInitiated callbacks on the same call ID).

 

Edit: typo

Message Edited by myraddin on 06-12-2009 10:49 AM


"Listen carefully, I shall say this only once"
New Developer
krishn2
Posts: 94
Registered: ‎03-06-2009
My Device: Not Specified

Re: Call Initiated event generated twice !!!!

I dit the same thing :smileyhappy:

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

Re: Call Initiated event generated twice !!!!

"since there is no way to get two callInitiated callbacks on the same call ID"

 

Hate to be the bearer of bad news, but call ids are not guaranteed unique:

 

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=917

 

Whether you can two at the same time with the same callid I don't know.

Developer
myraddin
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: Call Initiated event generated twice !!!!

@peter_strange.

 

Thx for the tip.

 

Bad news, that's for sure, but the mentioned bug does not interfere with the callInitiated callback.

I have never had any problems with the posted workaround which I use  in callInitiated and callFailed (just to mention a few).

 

 As for the bug... My guess is someone on the development team misinterpreted the active call to be the call waiting instead of the incoming call :smileyhappy:.

So, maybe they don't exactly guarantee call ID uniqueness, but I believe we can rely on it (except for the mentioned callWaiting bug).

 

In any case, even if someone empirically proves that we should not rely on it's uniqueness in callInitiated, we can allways use another guard by using krishn2's finding and with the memorized callID also store the phoneListener's reference.

 



"Listen carefully, I shall say this only once"