黑莓 - EventInjector 激活扬声器
我正在尝试为来电激活免提电话。我可以通过 EventInjector.KeyCodeEvent 以编程方式接受来电,但无法使用 KeyCodeEvent 打开扬声器。
我通过以下方法注册了电话侦听器。
Phone.addPhoneListener(instance);
然后我尝试在 callConnected 方法中激活扬声器,如下所示。
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);
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试在线程中使用您的代码,并在调用键之间使用 Thread.sleep(100) ,就像这样。
这可能会起作用吗
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
要激活扬声器,您可以使用以下代码:
For activating loudspeaker you can use this code: