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
Posts: 86
Registered: ‎11-19-2008
My Device: Not Specified

Re: Call Control functions like reject/disconnect

On the Bold/Storm I just use key injection for the moment, which does work
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: Call Control functions like reject/disconnect

Can you copy/paste a snippet of the injection code.

because I only succeeded in using the deprecated:

 

KeyCodeEvent inject = new EventInjector.KeyCodeEvent(EventInjector.KeyEvent.KEY_DOWN, Characters.ESCAPE, 0);

(for instance)

 

 

 



"Listen carefully, I shall say this only once"
New Developer
Posts: 86
Registered: ‎11-19-2008
My Device: Not Specified

Re: Call Control functions like reject/disconnect

I also use the deprecated code...which still works though (and it must work, since "deprecated" is just a suggestion to not use it since it may possibily be removed in future versions)
New Developer
Posts: 2
Registered: ‎12-11-2008
My Device: Not Specified

Re: Call Control functions like reject/disconnect

[ Edited ]

Hi, I am trying to make the phone application perform some actions like EndCall, Hold, Mute, etc. through its menu. I am getting the reference of the menu using phoneMenu = Ui.getUiEngine().getActiveScreen().getMenu(0); as specified in the previous posts. I am also getting the results mentioned in the previous posts through the Listener methods, but when I do the following, I reach a dead end.

 

I have a PhoneListener.phoneMenu static variable defined, which stores the reference to the Phone application Menu each time an event occurs and a listener method is invoked. I am doing this so that I can use the reference to perform the required action from my PhoneActions object.

 

Now, my problem here is that, whenever I call PhoneListener.phoneMenu.getSize() from a PhoneActions method, it throws java.lang.NullPointerException. How am I losing the reference here? Any help is appreciated.

 

 

The following code is in the class PhoneActions:

 

private void performAction(int action) {
try {
for (int i = 0; i < PhoneListener.phoneMenu.getSize(); i++) {
MenuItem mi = PhoneListener.phoneMenu.getItem(i);
System.out.println("menu " + i + " :" + mi.getOrdinal() + " - " + mi.toString());

if (mi.getOrdinal() == action) {
mi.run();
return;
}
}
} catch (Exception e) {
System.out.println(e.toString());
}

System.out.println("Invalid action");
}

 

The following code is from the PhoneListener class:

 

public static Menu phoneMenu;

 

public void callIncoming(int callId)
{
System.out.println("callIncoming() " + callId);
phoneMenu = Ui.getUiEngine().getActiveScreen().getMenu(0);
}

public void callInitiated(int callId)
{
System.out.println("callInitiated() " + callId);
phoneMenu = Ui.getUiEngine().getActiveScreen().getMenu(0);
}

etc. etc.

 

 

 

 

 

Message Edited by RJoy on 12-23-2008 04:29 PM
New Developer
Posts: 2
Registered: ‎12-11-2008
My Device: Not Specified

Re: Call Control functions like reject/disconnect

Bump.

 

Why does the Menu reference disappear after the Listener method exits?

New Developer
Posts: 18
Registered: ‎01-04-2009
My Device: Not Specified

Re: Call Control functions like answer/reject/disconnect/hold

Hi Folks,

  I have just joined the forum today; read the BlackBerry JDE 4.6.0 API doc. I didnt find any API to hang up the call.

 

  I am writing an application where i need to hangup the call (incoming and outgoing).

 

  Please let me know if there is a proper way to achieve it.

 

New Developer
Posts: 94
Registered: ‎03-06-2009
My Device: Not Specified

Re: Call Control functions like reject/disconnect

Hi,

 

The reason is whenever u make a call, BB starts PhoneListener instance in a new process andUi.getUiEngine() returns a new instance of UiEngine. u can test it out by printing UiEngine reference befor making a call and after making a call, inside callIncomin() callback.

i am also facing the same issue and dont know how to make it work.

 

--Prashant

New Developer
Posts: 94
Registered: ‎03-06-2009
My Device: Not Specified

Re: Call Control functions like reject/disconnect

sry forgot to mention:

As new PhoneListener instance is started in a new process and new stack, all the static references become "null".

New Developer
Posts: 4
Registered: ‎08-03-2009
My Device: Not Specified

Re: Call Control functions like answer/reject/disconnect/hold

Hi Mark

My team is trying here to end a call by injecting the EventInjector.KeyEvent.KEY_DOWN event on the ENDKEY key, (red / hang up key).

This works alright on most devices, but there are a couple of Bold and Curves that are showing trouble on it.They simply don't end the call.

The interesting thing is that we know the key down event is being handled by the OS, because we query what's the current active screen
before/after and we are positive it's the PhoneDialer, then we issue the KEY_DOWN event, we query once again what's the current active
(foreground) screen and it's our application.
 
Let me show you some logs from 2 BlackBerry Bold devices we have (also this same thing is happenign on a couple of Curves).

 

7/8/2009 13:11:11 - DaemonRunnable - Init Daemon for: 9000 device.
7/8/2009 13:27:12 - InterceptCallPhoneListener - ================== NEW CALL INITIATED =========================
7/8/2009 13:27:12 - InterceptCallPhoneListener - Call id: 1 initiated to the number: ?+1416366xxxx
7/8/2009 13:27:12 - InterceptCallPhoneListener - Before hang up active screen is: net.rim.device.apps.internal.phone.ActivePhoneScreen
7/8/2009 13:27:12 - DialerActiveState - KEYDOWN injected

7/8/2009 13:27:12 - InterceptCallPhoneListener - After hang up active screen is: com.xxxxx.xxxxx.screen.RedirectOutboundCallScreen
7/8/2009 13:27:12 - InterceptCallPhoneListener - Call id: 1 intercepted.

As we can see here, the foreground screen is net.rim.device.apps.internal.phone.ActivePhoneScreen prior to issuing the END KEY event, which is, well, correct.
Then we check the foreground screen again, right after issuing the END KEY event, and the foreground screen now has changed, and it is
com.xxxxx.xxxxx.screen.RedirectOutboundCallScreen. This means, the END KEY worked OK in the sense the current screen is dismissed.

 

Now, why does this not hang up the call? this is a mystery as of now.

Now compare this to a log of what we can see on another Bold device that is working alright:

5/8/2009 7:49:1 - InterceptCallPhoneListener - ================== NEW CALL INITIATED =========================
5/8/2009 7:49:1 - InterceptCallPhoneListener - Call id: 1 initiated to the number: +54115317xxxx
5/8/2009 7:49:1 - InterceptCallPhoneListener - Before hang up active screen is: net.rim.device.apps.internal.phone.ActivePhoneScreen
5/8/2009 7:49:1 - DialerActiveState - KEYDOWN injected
5/8/2009 7:49:1 - InterceptCallPhoneListener - After hang up active screen is: ccom.xxxxx.xxxxx.screen.RedirectOutboundCallScreen
5/8/2009 7:49:1 - InterceptCallPhoneListener - Call id: 1 intercepted.
5/8/2009 7:49:2 - InterceptCallPhoneListener - Call id: 1 disconnected.

As you can see we are receivng the DISCONNECTED event right after (in the same second) we send the ENDKEY event.

Any advise? Should we "hold" the red key down for some milliseconds? Or...? We are clueless. Any advise will be very much appreciated.

 

Thanks
Mario.

New Developer
Posts: 94
Registered: ‎03-06-2009
My Device: Not Specified

Re: Call Control functions like answer/reject/disconnect/hold

[ Edited ]

Try using below code. This works for me on BOLD and curves:

 

try { EventInjector.KeyCodeEvent pressEndKey = new EventInjector.KeyCodeEvent( KeyCodeEvent.KEY_DOWN,( char)Keypad.KEY_END,KeypadListener.STATUS_NOT_FROM_KEYPAD); EventInjector.KeyCodeEvent releaseEndKey = new EventInjector.KeyCodeEvent( KeyCodeEvent.KEY_UP,(char)Keypad.KEY_END,KeypadListener.STATUS_NOT_FROM_KEYPAD); EventInjector.invokeEvent(pressEndKey); Thread.sleep(50); EventInjector.invokeEvent(releaseEndKey); Thread.sleep(50); EventInjector.invokeEvent(pressEndKey); Thread.sleep(50); EventInjector.invokeEvent(releaseEndKey); Thread.sleep(50); }catch(Exception ex){ BBRACEventLogger.error("Exception in rejectCurrAndMakeNewCall",BBRACEventLogger.GROUP_GSM); }

 


 

 

 

Message Edited by krishn2 on 09-10-2009 02:46 AM