/** * Initiate connection to a profile of the remote bluetooth device. * * <p>Currently, the system supports only 1 connection to the headset/handsfree profile. The API * will automatically disconnect connected devices before connecting. * * <p>This API returns false in scenarios like the profile on the device is already connected or * Bluetooth is not turned on. When this API returns true, it is guaranteed that connection state * intent for the profile will be broadcasted with the state. Users can get the connection state * of the profile from this intent. * * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} permission. * * @param device Remote Bluetooth Device * @return false on immediate error, true otherwise * @hide */ public boolean connect(BluetoothDevice device) { if (DBG) log("connect(" + device + ")"); if (mService != null && isEnabled() && isValidDevice(device)) { try { return mService.connect(device); } catch (RemoteException e) { Log.e(TAG, Log.getStackTraceString(new Throwable())); return false; } } if (mService == null) Log.w(TAG, "Proxy not attached to service"); return false; }