Java Code Examples for android.media.AudioManager#ACTION_SCO_AUDIO_STATE_UPDATED

The following examples show how to use android.media.AudioManager#ACTION_SCO_AUDIO_STATE_UPDATED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BluetoothStateManager.java    From bcm-android with GNU General Public License v3.0 5 votes vote down vote up
private String getScoChangeIntent() {
    return AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED;
}
 
Example 2
Source File: BluetoothStateManager.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
private String getScoChangeIntent() {
  return AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED;
}
 
Example 3
Source File: AudioManagerAndroid.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Registers receiver for the broadcasted intent related the existence
 * of a BT SCO channel. Indicates if BT SCO streaming is on or off.
 */
private void registerForBluetoothScoIntentBroadcast() {
    IntentFilter filter = new IntentFilter(
            AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED);

    /** BroadcastReceiver implementation which handles changes in BT SCO. */
    mBluetoothScoReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            int state = intent.getIntExtra(
                    AudioManager.EXTRA_SCO_AUDIO_STATE,
                    AudioManager.SCO_AUDIO_STATE_DISCONNECTED);
            if (DEBUG) {
                logd("BroadcastReceiver.onReceive: a=" + intent.getAction()
                        + ", s=" + state
                        + ", sb=" + isInitialStickyBroadcast());
            }

            switch (state) {
                case AudioManager.SCO_AUDIO_STATE_CONNECTED:
                    mBluetoothScoState = STATE_BLUETOOTH_SCO_ON;
                    break;
                case AudioManager.SCO_AUDIO_STATE_DISCONNECTED:
                    if (mBluetoothScoState != STATE_BLUETOOTH_SCO_TURNING_OFF) {
                        // Bluetooth is probably powered off during the call.
                        // Update the existing device selection, but only if a specific
                        // device has already been selected explicitly.
                        if (deviceHasBeenRequested()) {
                            updateDeviceActivation();
                        }
                    }
                    mBluetoothScoState = STATE_BLUETOOTH_SCO_OFF;
                    break;
                case AudioManager.SCO_AUDIO_STATE_CONNECTING:
                    // do nothing
                    break;
                default:
                    loge("Invalid state");
            }
            if (DEBUG) {
                reportUpdate();
            }
        }
    };

    ContextUtils.getApplicationContext().registerReceiver(mBluetoothScoReceiver, filter);
}