当前位置: 首页>>代码示例>>Java>>正文


Java AudioManager.SCO_AUDIO_STATE_CONNECTED属性代码示例

本文整理汇总了Java中android.media.AudioManager.SCO_AUDIO_STATE_CONNECTED属性的典型用法代码示例。如果您正苦于以下问题:Java AudioManager.SCO_AUDIO_STATE_CONNECTED属性的具体用法?Java AudioManager.SCO_AUDIO_STATE_CONNECTED怎么用?Java AudioManager.SCO_AUDIO_STATE_CONNECTED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.media.AudioManager的用法示例。


在下文中一共展示了AudioManager.SCO_AUDIO_STATE_CONNECTED属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onReceive

@SuppressWarnings("deprecation")
      @Override
public void onReceive(Context context, Intent intent) {
	String action = intent.getAction();
	Log.d(THIS_FILE, ">>> BT SCO state changed !!! ");
	if(AudioManager.ACTION_SCO_AUDIO_STATE_CHANGED.equals(action)) {
		int status = intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE, AudioManager.SCO_AUDIO_STATE_ERROR );
		Log.d(THIS_FILE, "BT SCO state changed : " + status + " target is " + targetBt);
		audioManager.setBluetoothScoOn(targetBt);
		
		if(status == AudioManager.SCO_AUDIO_STATE_CONNECTED) {
			isBluetoothConnected = true;
		}else if(status == AudioManager.SCO_AUDIO_STATE_DISCONNECTED) {
			isBluetoothConnected = false;
		}
		
		if(btChangesListener != null) {
		    btChangesListener.onBluetoothStateChanged(status);
		}
	}
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:21,代码来源:BluetoothUtils8.java

示例2: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    if (intent == null) return;
    Log.w(TAG, "onReceive");

    synchronized (LOCK) {
        if (getScoChangeIntent().equals(intent.getAction())) {
            int status = intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE, AudioManager.SCO_AUDIO_STATE_ERROR);

            if (status == AudioManager.SCO_AUDIO_STATE_CONNECTED) {
                if (Build.VERSION.SDK_INT >= 11 && bluetoothHeadset != null) {
                    List<BluetoothDevice> devices = bluetoothHeadset.getConnectedDevices();

                    for (BluetoothDevice device : devices) {
                        if (bluetoothHeadset.isAudioConnected(device)) {
                            int deviceClass = device.getBluetoothClass().getDeviceClass();

                            if (deviceClass == BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE ||
                                    deviceClass == BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO ||
                                    deviceClass == BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET)
                            {
                                scoConnection = ScoConnection.CONNECTED;

                                if (wantsConnection) {
                                    AudioManager audioManager = ServiceUtil.getAudioManager(context);
                                    audioManager.setBluetoothScoOn(true);
                                }
                            }
                        }
                    }

                }
            }
        }
    }

    handleBluetoothStateChange();
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:38,代码来源:BluetoothStateManager.java

示例3: onReceive

@Override
public void onReceive(Context context, Intent intent) {
  if (intent == null) return;
  Log.w(TAG, "onReceive");

  synchronized (LOCK) {
    if (getScoChangeIntent().equals(intent.getAction())) {
      int status = intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE, AudioManager.SCO_AUDIO_STATE_ERROR);

      if (status == AudioManager.SCO_AUDIO_STATE_CONNECTED) {
        if (Build.VERSION.SDK_INT >= 11 && bluetoothHeadset != null) {
          List<BluetoothDevice> devices = bluetoothHeadset.getConnectedDevices();

          for (BluetoothDevice device : devices) {
            if (bluetoothHeadset.isAudioConnected(device)) {
              int deviceClass = device.getBluetoothClass().getDeviceClass();

              if (deviceClass == BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE ||
                  deviceClass == BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO ||
                  deviceClass == BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET)
              {
                scoConnection = ScoConnection.CONNECTED;

                if (wantsConnection) {
                  AudioManager audioManager = ServiceUtil.getAudioManager(context);
                  audioManager.setBluetoothScoOn(true);
                }
              }
            }
          }

        }
      }
    }
  }

  handleBluetoothStateChange();
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:38,代码来源:BluetoothStateManager.java


注:本文中的android.media.AudioManager.SCO_AUDIO_STATE_CONNECTED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。