1

I am trying to activate the speaker-phone for an incoming call. I am able to accept the incoming call programatically through the EventInjector.KeyCodeEvent, but I am not able to turn on the speaker-phone with the KeyCodeEvent.

I registered with Phone listener through the following method.

Phone.addPhoneListener(instance);

then I try to activate the speaker in the callConnected method as follows.

EventInjector.KeyCodeEvent speakerKeyDown = 
    new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEvent.KEY_DOWN,
        (char) Keypad.KEY_SPEAKERPHONE, KeypadListener.STATUS_NOT_FROM_KEYPAD);
EventInjector.KeyCodeEvent speakerKeyUp = 
    new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEvent.KEY_UP,
        (char) Keypad.KEY_SPEAKERPHONE, KeypadListener.STATUS_NOT_FROM_KEYPAD);
EventInjector.invokeEvent(speakerKeyDown);
EventInjector.invokeEvent(speakerKeyUp);
Michael Donohue
  • 11,776
  • 5
  • 31
  • 44
venu88
  • 41
  • 4

2 Answers2

0

Try to use your code within a thread and use Thread.sleep(100) between the invoking of the key just like that.

Might this will work

EventInjector.invokeEvent(speakerKeyDown);
Thread.sleep(100);
EventInjector.invokeEvent(speakerKeyUp);
Thread.sleep(100);
Murtz
  • 108
  • 1
  • 8
  • Its still not working. How ever after the introducing the above mentioned code **Mute** is activated instead of the Speaker phone. – venu88 Nov 03 '11 at 15:26
  • Earlier at some times it used to activate the mute Key but now mute key is always activated. – venu88 Nov 03 '11 at 15:47
0

For activating loudspeaker you can use this code:

EventInjector.KeyCodeEvent speakerKeyDown =  new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEvent.KEY_DOWN,(char)Keypad.key(2359296),KeypadListener.STATUS_NOT_FROM_KEYPAD);
EventInjector.KeyCodeEvent speakerKeyUp   =  new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEvent.KEY_UP,(char)Keypad.key(2359296),KeypadListener.STATUS_NOT_FROM_KEYPAD);
EventInjector.invokeEvent(speakerKeyDown);
try{Thread.sleep(500);}catch(Exception e){}
EventInjector.invokeEvent(speakerKeyUp);
JJJ
  • 32,902
  • 20
  • 89
  • 102
nitin tyagi
  • 1,176
  • 1
  • 19
  • 52