ACTION_HEADSET_PLUG延时播出 [英] ACTION_HEADSET_PLUG broadcast delay

查看:408
本文介绍了ACTION_HEADSET_PLUG延时播出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Intent.ACTION_HEADSET_PLUG 动作我自己的广播接收器实例。有拔下耳机片刻实际的物理之间约1-2秒延时,当我的广播接收器通知有关。

I have my own BroadcastReceiver instance for Intent.ACTION_HEADSET_PLUG action. There is about 1-2 seconds delay between actual physical unplugging a headset and a moment when my BroadcastReceiver is notified about that.

IntentFilter filter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY - 1);
registerReceiver(new BroadcastReceiver() {

  @Override
  public void onReceive(Context context, Intent intent) {
    // my code here
  }
}, filter);

任何想法如何降低延迟?

Any ideas how to decrease the delay?

推荐答案

处理 AudioManager.ACTION_AUDIO_BECOMING_NOISY 广播做了:)它的意图后,耳机直播的诀窍是不插电任何延迟。

Handling AudioManager.ACTION_AUDIO_BECOMING_NOISY broadcast did the trick :) Its intent is broadcast directly after headset is unplugged without any delay.

这篇关于ACTION_HEADSET_PLUG延时播出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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