BlackBerry编程

编程入门 行业动态 更新时间:2024-10-21 09:51:59
BlackBerry编程 - 侧面硬件音量按钮(BlackBerry programming - Side hardware volume buttons)

有没有办法知道用户是否按下手机侧面的两个硬件音量按钮之一?

Is there a way to know if users press one of the two hardware volume buttons on the side of the phone?

最满意答案

在MainScreen或FullScreen类上,重写以下方法:

protected boolean keyControl(char key, int status, int time) { switch (key) { case Characters.CONTROL_VOLUME_UP: // Do something return true; case Characters.CONTROL_VOLUME_DOWN: // Do something return true; default: return super.keyCharUnhandled(key, status, time); } }

需要注意的是,这仅适用于您的应用和该屏幕位于前台的情况。 如果您希望在应用程序处于后台时允许用户使用音量键,则您需要使用BlackBerry Media Actions API ,该API仅在5.0及更高版本上可用。

On your MainScreen or FullScreen class, override the following method:

protected boolean keyControl(char key, int status, int time) { switch (key) { case Characters.CONTROL_VOLUME_UP: // Do something return true; case Characters.CONTROL_VOLUME_DOWN: // Do something return true; default: return super.keyCharUnhandled(key, status, time); } }

The caveat being that this only works when your app and that screen are in the foreground. If you want to allow users to use the volume keys while your app is in the background, you'll need to use the BlackBerry Media Actions API, which is only available on 5.0 and above.

更多推荐

本文发布于:2023-07-24 00:23:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1239229.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:BlackBerry

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!