keydown 文档指出,如果它被按住,keydown 将再次发送,但如果你按住媒体键,我根本不会收到任何通知。有没有办法检测到这一点?它实际上是谷歌(现在?)搜索语音输入 - 也许有一个广播表明我可以接收到正在发生的事情?
这是我BroadcastReceiver
的接收器:
@Override
public void onReceive(Context context, Intent intent)
{
String intentAction = intent.getAction();
int SoundID = 0;
if (Intent.ACTION_MEDIA_BUTTON.equals(intentAction))
{
KeyEvent event = (KeyEvent)intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
if (event != null)
{
int action = event.getAction();
if (action == KeyEvent.ACTION_DOWN)
{
Log.d("Hi", "MEDIA keydown r" + event.getRepeatCount());
if (event.getRepeatCount() == 1)
DoSomethingMagical();
else if (event.getRepeatCount() == 0)
DoSomethingSpecial();
}
}
}
}