List of usage examples for android.bluetooth BluetoothAdapter STATE_TURNING_ON
int STATE_TURNING_ON
To view the source code for android.bluetooth BluetoothAdapter STATE_TURNING_ON.
Click Source Link
From source file:ac.robinson.bettertogether.hotspot.HotspotManagerService.java
private void connectBluetoothHotspot(@NonNull ConnectionOptions options) { Log.d(TAG, "Attempting connection via Bluetooth"); switch (mBluetoothAdapter.getState()) { case BluetoothAdapter.STATE_ON: Log.d(TAG, "Starting Bluetooth discovery"); mBluetoothAdapter.cancelDiscovery(); mBluetoothAdapter.startDiscovery(); setBluetoothErrorTimeout();/* w w w.j a v a2 s .co m*/ break; case BluetoothAdapter.STATE_TURNING_ON: Log.d(TAG, "Waiting for Bluetooth to be enabled"); break; // start discovery in receiver case BluetoothAdapter.STATE_OFF: case BluetoothAdapter.STATE_TURNING_OFF: default: Log.d(TAG, "Enabling Bluetooth / waiting for receiver to enable"); mBluetoothAdapter.enable(); // start discovery in receiver } }
From source file:com.evothings.BLE.java
private void reset(final CordovaArgs args, final CallbackContext cc) throws JSONException { mResetCallbackContext = null;// w w w .java2 s . c o m BluetoothAdapter a = BluetoothAdapter.getDefaultAdapter(); if (mScanCallbackContext != null) { a.stopLeScan(this); mScanCallbackContext = null; } int state = a.getState(); //STATE_OFF, STATE_TURNING_ON, STATE_ON, STATE_TURNING_OFF. if (state == BluetoothAdapter.STATE_TURNING_ON) { // reset in progress; wait for STATE_ON. mResetCallbackContext = cc; return; } if (state == BluetoothAdapter.STATE_TURNING_OFF) { // reset in progress; wait for STATE_OFF. mResetCallbackContext = cc; return; } if (state == BluetoothAdapter.STATE_OFF) { boolean res = a.enable(); if (res) { mResetCallbackContext = cc; } else { cc.error("enable"); } return; } if (state == BluetoothAdapter.STATE_ON) { boolean res = a.disable(); if (res) { mResetCallbackContext = cc; } else { cc.error("disable"); } return; } cc.error("Unknown state: " + state); }
From source file:com.android.launcher3.widget.DigitalAppWidgetProvider.java
private void refreshBtStatus(Context context, RemoteViews widget) { bluetoothManager = (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE); bluetoothApapter = bluetoothManager.getAdapter(); if (bluetoothApapter != null) { int btStatus = bluetoothApapter.getState(); if (BluetoothAdapter.STATE_ON == btStatus || BluetoothAdapter.STATE_TURNING_ON == btStatus) { widget.setImageViewResource(R.id.bt, R.drawable.status_bt_on); } else {/*w w w . j a v a 2 s . c om*/ widget.setImageViewResource(R.id.bt, R.drawable.ic_qs_bluetooth_off_sprd); } } }