这样才能保证中兴T815 Android手机交付行动HEADSET_PLUG的 [英] Way to ensure delivery of Action HEADSET_PLUG for ZTE T815 Android phone

查看:199
本文介绍了这样才能保证中兴T815 Android手机交付行动HEADSET_PLUG的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经注册一个BroadcastReceiver接收ACTION_HEADSET_PLUG这对于大多数设备工作正常,即每当耳机插入或拔下它被调用。但在其他如中兴T815,其意图是从来没有当耳机插入发送/接收/拔出。

有关参考这里是code接收机注册:

 私人最终的BroadcastReceiver headsetPlugReceiver =新的广播接收器(){    @覆盖
    公共无效的onReceive(上下文的背景下,意图意图){
        Log.d(TAG,收到的意图=+意向);
        如果(intent.getAction()。equalsIgnoreCase(Intent.ACTION_HEADSET_PLUG)){
            //做的东西
        }
    }
};公共无效的onCreate(捆绑savedState){
    super.onCeate(savedState);
    // ...
    registerReceiver(headsetPlugReceiver,新的IntentFilter(Intent.ACTION_HEADSET_PLUG));
}

更多信息:
其目的是派出,但HEADSET_HOOK命令在耳机解雇之后。

而当意图是派出

 最终诠释麦克风= intent.getIntExtra(话筒,0);

总是返回0(即没有麦克风)。

所以


  1. 有一些配置/ code,它可以迫使这个交付
    意图?

  2. 如何获得的意图,正确地报告是否
    麦克风的存在与否?


解决方案

原来,中兴T815具有OMTP TRRS配置其音频插孔,而不是CTIA / AHJ像其他现代的Andr​​oid设备。

请参阅 http://en.wikipedia.org/wiki/Phone_connector_%28audio%29

事务中的悲惨状态,尝试使用音频供给inpout跨产品时尤其如此。

I have registered a BroadcastReceiver to receive ACTION_HEADSET_PLUG which works fine for most devices, ie it is called whenever the headset is plugged or unplugged. But on others eg the ZTE T815, the Intent is never sent/received when the headset is plugged/unplugged.

For reference here is the code for the receiver registration:

private final BroadcastReceiver headsetPlugReceiver = new BroadcastReceiver() {

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.d(TAG, "Received intent=" + intent);
        if (intent.getAction().equalsIgnoreCase(Intent.ACTION_HEADSET_PLUG)) {
            // do stuff
        }
    }
};

public void onCreate(Bundle savedState) {
    super.onCeate(savedState);
    // ...
    registerReceiver(headsetPlugReceiver, new IntentFilter(Intent.ACTION_HEADSET_PLUG));
}

Further info: The Intent is dispatched but only after the HEADSET_HOOK command is fired on the headset.

And when the Intent is dispatched

final int microphone = intent.getIntExtra("microphone", 0);

always returns 0 (ie no microphone).

So

  1. Is there some config/code that can force the delivery of this Intent?
  2. How do I get the Intent to correctly report whether a microphone exists or not?

解决方案

It turns out the ZTE T815 has an OMTP TRRS config for its audio socket instead of CTIA/AHJ like every other modern Android device.

See http://en.wikipedia.org/wiki/Phone_connector_%28audio%29

A sad state of affairs, especially when trying to use audio feed inpout across products.

这篇关于这样才能保证中兴T815 Android手机交付行动HEADSET_PLUG的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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