本文整理汇总了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);
}
}
}
示例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();
}
示例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();
}