如何为Codename One中的物理卷键分配操作? [英] How to assign an action to the physical volume keys in Codename One?

查看:58
本文介绍了如何为Codename One中的物理卷键分配操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的Codename One应用对音量调高/调低键(位于设备侧的物理键)做出反应.实际上,我已经有一个执行操作的按钮,但我也想提供使用音量键启动操作的可能性.

I would like my Codename One app to react to volume up / down keys (the physical keys that lay on the device side). Actually I already have a button that does the action but I would also like to offer the possibility to use the volume keys to launch the action.

我找到了原型读取的方法 keyPressed()

I found the method keyPressed() which prototype reads

public void keyPressed(int keyCode)

但是我无法真正找到调高音量的keyCode常数.

but I was not able to actually find the keyCode constant for volume up / down.

如何将音量调高/调低键分配给代号为One的动作?

How can I assign the volume up / down keys to an action with Codename One ?

任何帮助表示赞赏,

推荐答案

按下/释放的键将不会被调用以进行音量控制,因为这在本机调用链中太深了,并且非常依赖于设备.音量键始终被视为一种特殊情况,因此我们让它们执行预期的操作"并提供一些量身定制的回调,但是我们不支持重新使用"音量键的用例.

Key pressed/released won't be invoked for volume since that is way too deep in the native call chain and very device dependent. Volume keys are always treated as a special case so we make them do "what's expected" and provide some tailored callbacks but we don't support the use case of "re-purposing" volume keys.

可能可以通过更改 AndroidImplementation 类以使其包含特例(可能通过display属性触发)并为此提交请求请求.

It might be possible by changing the AndroidImplementation class to include a special case (possibly triggered via a display property) and submitting a pull request for that.

这篇关于如何为Codename One中的物理卷键分配操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆