Java Code Examples for android.bluetooth.BluetoothAdapter#STATE_CONNECTING
The following examples show how to use
android.bluetooth.BluetoothAdapter#STATE_CONNECTING .
These examples are extracted from open source projects.
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 Project: sdl_java_suite File: SdlBroadcastReceiver.java License: BSD 3-Clause "New" or "Revised" License | 7 votes |
@SuppressWarnings({"MissingPermission"}) private static boolean isBluetoothConnected() { BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if(bluetoothAdapter != null && bluetoothAdapter.isEnabled()) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) { int a2dpState = bluetoothAdapter.getProfileConnectionState(BluetoothProfile.A2DP); int headSetState = bluetoothAdapter.getProfileConnectionState(BluetoothProfile.HEADSET); return ((a2dpState == BluetoothAdapter.STATE_CONNECTED || a2dpState == BluetoothAdapter.STATE_CONNECTING) && (headSetState == BluetoothAdapter.STATE_CONNECTED || headSetState == BluetoothAdapter.STATE_CONNECTING)); }else{ return true; } } return false; }
Example 2
Source Project: sdl_java_suite File: MediaStreamingStatus.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
@SuppressLint("MissingPermission") boolean isBluetoothActuallyAvailable(){ BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); if(adapter == null || !adapter.isEnabled() ){ //False positive return false; } if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH ){ int state = adapter.getProfileConnectionState(BluetoothProfile.A2DP); if(state != BluetoothAdapter.STATE_CONNECTING && state != BluetoothAdapter.STATE_CONNECTED){ //False positive return false; } } return true; }
Example 3
Source Project: imsdk-android File: AppRTCBluetoothManager.java License: MIT License | 5 votes |
/** Converts BluetoothAdapter states into local string representations. */ private String stateToString(int state) { switch (state) { case BluetoothAdapter.STATE_DISCONNECTED: return "DISCONNECTED"; case BluetoothAdapter.STATE_CONNECTED: return "CONNECTED"; case BluetoothAdapter.STATE_CONNECTING: return "CONNECTING"; case BluetoothAdapter.STATE_DISCONNECTING: return "DISCONNECTING"; case BluetoothAdapter.STATE_OFF: return "OFF"; case BluetoothAdapter.STATE_ON: return "ON"; case BluetoothAdapter.STATE_TURNING_OFF: // Indicates the local Bluetooth adapter is turning off. Local clients should immediately // attempt graceful disconnection of any remote links. return "TURNING_OFF"; case BluetoothAdapter.STATE_TURNING_ON: // Indicates the local Bluetooth adapter is turning on. However local clients should wait // for STATE_ON before attempting to use the adapter. return "TURNING_ON"; default: return "INVALID"; } }
Example 4
Source Project: flutter-incall-manager File: AppRTCBluetoothManager.java License: ISC License | 5 votes |
/** Converts BluetoothAdapter states into local string representations. */ private String stateToString(int state) { switch (state) { case BluetoothAdapter.STATE_DISCONNECTED: return "DISCONNECTED"; case BluetoothAdapter.STATE_CONNECTED: return "CONNECTED"; case BluetoothAdapter.STATE_CONNECTING: return "CONNECTING"; case BluetoothAdapter.STATE_DISCONNECTING: return "DISCONNECTING"; case BluetoothAdapter.STATE_OFF: return "OFF"; case BluetoothAdapter.STATE_ON: return "ON"; case BluetoothAdapter.STATE_TURNING_OFF: // Indicates the local Bluetooth adapter is turning off. Local clients should immediately // attempt graceful disconnection of any remote links. return "TURNING_OFF"; case BluetoothAdapter.STATE_TURNING_ON: // Indicates the local Bluetooth adapter is turning on. However local clients should wait // for STATE_ON before attempting to use the adapter. return "TURNING_ON"; default: return "INVALID"; } }
Example 5
Source Project: AssistantBySDK File: AssistantService.java License: Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { Log.i(TAG, "blueConnectStateBroadcastReceiver action>>>>" + intent.getAction()); if (intent.getAction() == null) return; if (intent.getAction().equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) { int blueconState = intent.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE, 0); switch (blueconState) { case BluetoothAdapter.STATE_CONNECTED: Log.i(TAG, "blueConnectStateBroadcastReceiver>>>>STATE_CONNECTED"); voiceMediator.setBlueHeadSet(true); isBlueToothHeadsetConnected(); break; case BluetoothAdapter.STATE_CONNECTING: Log.i(TAG, "blueConnectStateBroadcastReceiver>>>>STATE_CONNECTING"); break; case BluetoothAdapter.STATE_DISCONNECTED: Log.i(TAG, "blueConnectStateBroadcastReceiver>>>>STATE_DISCONNECTED"); voiceMediator.setBlueHeadSet(false); voiceMediator.setSuportA2DP(false); AudioManager mAudioManager_ = (AudioManager) getSystemService(Context.AUDIO_SERVICE); mAudioManager_.setBluetoothScoOn(false); mAudioManager_.stopBluetoothSco(); break; case BluetoothAdapter.STATE_DISCONNECTING: Log.i(TAG, "blueConnectStateBroadcastReceiver>>>>STATE_DISCONNECTING"); voiceMediator.setSuportA2DP(false); break; default: break; } } }
Example 6
Source Project: react-native-incall-manager File: AppRTCBluetoothManager.java License: ISC License | 5 votes |
/** Converts BluetoothAdapter states into local string representations. */ private String stateToString(int state) { switch (state) { case BluetoothAdapter.STATE_DISCONNECTED: return "DISCONNECTED"; case BluetoothAdapter.STATE_CONNECTED: return "CONNECTED"; case BluetoothAdapter.STATE_CONNECTING: return "CONNECTING"; case BluetoothAdapter.STATE_DISCONNECTING: return "DISCONNECTING"; case BluetoothAdapter.STATE_OFF: return "OFF"; case BluetoothAdapter.STATE_ON: return "ON"; case BluetoothAdapter.STATE_TURNING_OFF: // Indicates the local Bluetooth adapter is turning off. Local clients should immediately // attempt graceful disconnection of any remote links. return "TURNING_OFF"; case BluetoothAdapter.STATE_TURNING_ON: // Indicates the local Bluetooth adapter is turning on. However local clients should wait // for STATE_ON before attempting to use the adapter. return "TURNING_ON"; default: return "INVALID"; } }
Example 7
Source Project: Pix-Art-Messenger File: AppRTCBluetoothManager.java License: GNU General Public License v3.0 | 5 votes |
/** * Converts BluetoothAdapter states into local string representations. */ private String stateToString(int state) { switch (state) { case BluetoothAdapter.STATE_DISCONNECTED: return "DISCONNECTED"; case BluetoothAdapter.STATE_CONNECTED: return "CONNECTED"; case BluetoothAdapter.STATE_CONNECTING: return "CONNECTING"; case BluetoothAdapter.STATE_DISCONNECTING: return "DISCONNECTING"; case BluetoothAdapter.STATE_OFF: return "OFF"; case BluetoothAdapter.STATE_ON: return "ON"; case BluetoothAdapter.STATE_TURNING_OFF: // Indicates the local Bluetooth adapter is turning off. Local clients should immediately // attempt graceful disconnection of any remote links. return "TURNING_OFF"; case BluetoothAdapter.STATE_TURNING_ON: // Indicates the local Bluetooth adapter is turning on. However local clients should wait // for STATE_ON before attempting to use the adapter. return "TURNING_ON"; default: return "INVALID"; } }
Example 8
Source Project: Rumble File: BluetoothUtil.java License: GNU General Public License v3.0 | 5 votes |
public static boolean isWorking() { BluetoothAdapter adapter = BluetoothUtil.getBluetoothAdapter(RumbleApplication.getContext()); if ( adapter == null) return false; return ((adapter.getScanMode() == BluetoothAdapter.STATE_CONNECTING) || (adapter.getScanMode() == BluetoothAdapter.STATE_DISCONNECTING) ); }
Example 9
Source Project: Conversations File: AppRTCBluetoothManager.java License: GNU General Public License v3.0 | 5 votes |
/** * Converts BluetoothAdapter states into local string representations. */ private String stateToString(int state) { switch (state) { case BluetoothAdapter.STATE_DISCONNECTED: return "DISCONNECTED"; case BluetoothAdapter.STATE_CONNECTED: return "CONNECTED"; case BluetoothAdapter.STATE_CONNECTING: return "CONNECTING"; case BluetoothAdapter.STATE_DISCONNECTING: return "DISCONNECTING"; case BluetoothAdapter.STATE_OFF: return "OFF"; case BluetoothAdapter.STATE_ON: return "ON"; case BluetoothAdapter.STATE_TURNING_OFF: // Indicates the local Bluetooth adapter is turning off. Local clients should immediately // attempt graceful disconnection of any remote links. return "TURNING_OFF"; case BluetoothAdapter.STATE_TURNING_ON: // Indicates the local Bluetooth adapter is turning on. However local clients should wait // for STATE_ON before attempting to use the adapter. return "TURNING_ON"; default: return "INVALID"; } }