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.
更多推荐
发布评论