黑莓 - EventInjector 激活扬声器

发布于 2024-12-12 13:40:47 字数 719 浏览 2 评论 0原文

我正在尝试为来电激活免提电话。我可以通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

滥情空心 2024-12-19 13:40:47

尝试在线程中使用您的代码,并在调用键之间使用 Thread.sleep(100) ,就像这样。

这可能会起作用吗

EventInjector.invokeEvent(speakerKeyDown);
Thread.sleep(100);
EventInjector.invokeEvent(speakerKeyUp);
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

EventInjector.invokeEvent(speakerKeyDown);
Thread.sleep(100);
EventInjector.invokeEvent(speakerKeyUp);
Thread.sleep(100);
似梦非梦 2024-12-19 13:40:47

要激活扬声器,您可以使用以下代码:

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);

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文