作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有一个从 onKeyDown 事件返回的日志,标志的结果是数字 520。我如何找出标志是什么?我假设它的 520 = 512 + 8 = FLAG_TRACKING + FLAG_FROM_SYSTEM
我需要确定,我听说它与十六进制代码有关。我如何转换并找出?
来自日志:
onKeyUp - 键码:118 |信息:KeyEvent{action=ACTION_UP code=118 repeat=0 meta=0 scancode=766 mFlags=520}
我需要知道 mFlags 的名称是什么。
谢谢。
最佳答案
完整代码如下:
Log.i("==BCR==", "onKeyDown - keycode: " + keyCode + " | isCanceled: " + event.isCanceled() + " | info: " + event.toString());
if ((event.getFlags() & KeyEvent.FLAG_FROM_SYSTEM) == KeyEvent.FLAG_FROM_SYSTEM)
{
Log.i("==BCR==", "onKeyDown - keycode: " + keyCode + " | FLAG: FLAG_FROM_SYSTEM");
}else {}
if ((event.getFlags() & KeyEvent.FLAG_TRACKING) == KeyEvent.FLAG_TRACKING)
{
Log.i("==BCR==", "onKeyDown - keycode: " + keyCode + " | FLAG: FLAG_TRACKING");
}else {}
///FLAG_WOKE_HERE
if ((event.getFlags() & KeyEvent.FLAG_WOKE_HERE) == KeyEvent.FLAG_WOKE_HERE)
{
Log.i("==BCR==", "onKeyDown - keycode: " + keyCode + " | FLAG: FLAG_WOKE_HERE");
}else {}
//FLAG_SOFT_KEYBOARD
if ((event.getFlags() & KeyEvent.FLAG_SOFT_KEYBOARD) == KeyEvent.FLAG_SOFT_KEYBOARD)
{
Log.i("==BCR==", "onKeyDown - keycode: " + keyCode + " | FLAG: FLAG_SOFT_KEYBOARD");
}else {}
//FLAG_KEEP_TOUCH_MODE
if ((event.getFlags() & KeyEvent.FLAG_KEEP_TOUCH_MODE) == KeyEvent.FLAG_KEEP_TOUCH_MODE)
{
Log.i("==BCR==", "onKeyDown - keycode: " + keyCode + " | FLAG: FLAG_KEEP_TOUCH_MODE");
}else {}
//FLAG_EDITOR_ACTION
if ((event.getFlags() & KeyEvent.FLAG_EDITOR_ACTION) == KeyEvent.FLAG_EDITOR_ACTION)
{
Log.i("==BCR==", "onKeyDown - keycode: " + keyCode + " | FLAG: FLAG_EDITOR_ACTION");
}else {}
//FLAG_CANCELED
if ((event.getFlags() & KeyEvent.FLAG_CANCELED) == KeyEvent.FLAG_CANCELED)
{
Log.i("==BCR==", "onKeyDown - keycode: " + keyCode + " | FLAG: FLAG_CANCELED");
}else {}
//FLAG_VIRTUAL_HARD_KEY
if ((event.getFlags() & KeyEvent.FLAG_VIRTUAL_HARD_KEY) == KeyEvent.FLAG_VIRTUAL_HARD_KEY)
{
Log.i("==BCR==", "onKeyDown - keycode: " + keyCode + " | FLAG: FLAG_VIRTUAL_HARD_KEY");
}else {}
//FLAG_LONG_PRESS
if ((event.getFlags() & KeyEvent.FLAG_LONG_PRESS) == KeyEvent.FLAG_LONG_PRESS)
{
Log.i("==BCR==", "onKeyDown - keycode: " + keyCode + " | FLAG: FLAG_LONG_PRESS");
}else {}
//FLAG_CANCELED_LONG_PRESS
if ((event.getFlags() & KeyEvent.FLAG_CANCELED_LONG_PRESS) == KeyEvent.FLAG_CANCELED_LONG_PRESS)
{
Log.i("==BCR==", "onKeyDown - keycode: " + keyCode + " | FLAG: FLAG_CANCELED_LONG_PRESS");
}else {}
关于android - onKeyDown mFlags 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7111851/
我有一个从 onKeyDown 事件返回的日志,标志的结果是数字 520。我如何找出标志是什么?我假设它的 520 = 512 + 8 = FLAG_TRACKING + FLAG_FROM_SYST
我是一名优秀的程序员,十分优秀!