编程方式检测硬件调用presence /挂断键 [英] Programatically detect presence of hardware call/hang up keys
问题描述
我的一个客户想要一个返回boolean值的code方法。如果Android手机硬件有红色/绿色的通话/挂机键真假,如果它不。
One of my clients wants a code method that returns a boolean. True if the Android phone has hardware red/green call/hang up keys and false if it does not.
Sonething是这样的:
Sonething like this :
public void keyFeedbackFromInput(KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN
&& (event.getFlags() & KeyEvent.FLAG_VIRTUAL_HARD_KEY) != 0) {
// perform your logic here
}
}
但不是在一个关键的preSS事件如上面的code片段。他需要确定这个锋线,如果手机有物理红/绿键或虚拟的。
But not in a key press event as in the code snippet above. He needs to determine this up front if a phone has physical red/green keys or virtual ones.
是否有可能,如果是有人可以提供code样品实现这一目标?
Is it possible and if yes can someone provide a code sample to achieve this?
推荐答案
编辑:
有没有调用来获取这些信息后。
您可以尝试具有 Build.MODEL
字典的关键。
是这样的:
There is no call to get that kind of info.
You can try having a dictionary with Build.MODEL
as key.
Something like:
/* Create the dictionary */
private HashMap<String, Boolean> redGreenKeys = new HashMap<String, Boolean>();
redGreenKeys.put("Milestone", false);
public Boolean hasRedGreenButtons() {
Boolean ret = redGreenKeys.get(Build.MODEL);
if ( ret == null )
return false;
return ret;
}
这篇关于编程方式检测硬件调用presence /挂断键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!