我有自己BroadcastReceiver
的行动实例Intent.ACTION_HEADSET_PLUG
。在实际拔出耳机和BroadcastReceiver
通知我的那一刻之间大约有 1-2 秒的延迟。
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);
任何想法如何减少延迟?