Connect paired bluetooth device

Programmatically connect to paired Bluetooth device

Is there a way, using the Android SDK, to programmatically connect to an already-paired Bluetooth device? In other words: I can go into Settings -> Wireless & networks -> Bluetooth settings, and tap the device (listed as «Paired but not connected»), at which point it will connect. I’d like to be able to do this programmatically, but don’t see a way to do this. I see the options to create an RFCOMM socket, and for a SPP device, I’m assuming that’ll do the connection part as well, but for an A2DP device, where the actual data transfer will be handled by the OS rather than by my app, I think that’s not applicable?

4 Answers 4

Okay, since this was driving me crazy, I did some digging into the source code and I’ve found a 100% reliable (at least on my Nexus 4, Android 4.3) solution to connect to a paired A2DP device (such as a headset or Bluetooth audio device). I’ve published a fully working sample project (easily built with Android Studio) that you can find here on Github.

Essentially, what you need to do is:

  • Get an instance of the BluetoothAdapter
  • Using this instance, get a profile proxy for A2DP:

adapter.getProfileProxy (context, listener, BluetoothProfile.A2DP);

where listener is a ServiceListener that will receive a BluetoothProfile in its onServiceConnected() callback (which can be cast to a BluetoothA2dp instance)

Method connect = BluetoothA2dp.class.getDeclaredMethod(«connect», BluetoothDevice.class);

String deviceName = "My_Device_Name"; BluetoothDevice result = null; Set devices = adapter.getBondedDevices(); if (devices != null) < for (BluetoothDevice device : devices) < if (deviceName.equals(device.getName())) < result = device; break; >> > 

Which, at least for me, caused an immediate connection of the device.

Источник

Pair a Bluetooth device in Windows

You can pair all kinds of Bluetooth devices with your PC—including keyboards, mice, phones, speakers, and a whole lot more. To do this, your PC needs to have Bluetooth. Some PCs, such as laptops and tablets, have Bluetooth built in. If your PC doesn’t, you can plug a USB Bluetooth adapter into the USB port on your PC to get it.

Before you start, make sure that your Windows 11 PC supports Bluetooth. For more info on how to check, see Fix Bluetooth problems in Windows. If you need help adding a device without Bluetooth capabilities, see Add a device to a Windows PC.

Читайте также:  Microsoft atom desktop bluetooth

Turn on Bluetooth

After you’ve checked that your Windows 11 PC supports Bluetooth, you’ll need to turn it on. Here’s how:

  • In Settings: Select Start >Settings >Bluetooth & devices , and then turn on Bluetooth .
  • In quick settings: To find the quick setting for Bluetooth, select the Network, Sound, or Battery icons ( ) next to the time and date on the right side of your taskbar. Select Bluetooth to turn it on. If it’s turned on without any Bluetooth devices connected, it might appear as Not connected .

The Bluetooth button in

To pair a Bluetooth device

  1. Turn on your Bluetooth device and make it discoverable. The way you make it discoverable depends on the device. Check the device or visit the manufacturer’s website to learn how.
  2. On your PC, select the Network , Sound, or Battery icons ( ) next to the time and date on the right side of your taskbar.
  3. Select Manage Bluetooth devices on the Bluetooth quick setting, then select your device under New devices.

The Manage Bluetooth devices button in Quick Settings.

  • Follow additional instructions if they appear, then select Done.
  • Your Bluetooth device and PC will usually automatically connect anytime the two devices are in range of each other with Bluetooth turned on.

    Tip: If you don’t see the Bluetooth device you want displayed in the list, you may need to set the Bluetooth devices discovery setting to Advanced. To learn how, see Fix Bluetooth problems in Windows.

    To pair a Bluetooth printer or scanner

    1. Turn on your Bluetooth printer or scanner and make it discoverable. The way you make it discoverable depends on the device. Check the device or visit the manufacturer’s website to learn how.
    2. Select Start >Settings >Bluetooth & devices >Printers & scanners >Add device. Wait for it to find nearby printers, choose the one you want to use, then select Add device.

    If you’re having problems installing your printer or scanner, see either Fix printer problems or Install and use a scanner in Windows.

    To pair a Bluetooth device using Swift Pair

    Swift Pair in Windows 11 lets you quickly pair a supported Bluetooth device with your PC. If the Bluetooth device supports Swift Pair, you’ll receive a notification when it’s nearby and you put it into pairing mode to make it discoverable.

    1. Turn on a Bluetooth device that supports Swift Pair and make it discoverable. The way you make it discoverable depends on the device. Check the device or visit the manufacturer’s website to learn more.
    2. If this is your first time using Swift Pair, select Yes when asked if you want to get notifications and use Swift Pair.
    3. When a notification appears that a new Bluetooth device was found, select Connect.

    Before you start, make sure that your Windows 10 PC supports Bluetooth. For more info on how to check, see Fix Bluetooth problems in Windows 10. If you need help adding a device without Bluetooth capabilities, see Add a device to a Windows 10 PC.

    Turn on Bluetooth

    After you’ve checked that your Windows 10 PC supports Bluetooth, you’ll need to turn it on. Here’s how:

    In Settings: Select Start > Settings > Devices > Bluetooth & other devices, and turn on Bluetooth.

    In action center: Action center can be found next to time and date on your taskbar. On the taskbar, select action center ( or ), then select Bluetooth to turn it on. If it’s turned off, it might appear as Not connected.

    If you don’t see Bluetooth in your action center, here’s how you can change it:

    • Expand quick actions. On the taskbar, select action center ( or ) >Expand. Bluetooth should appear here. It will appear as Bluetooth or Not connected.
    • Add Bluetooth to action center. Select Start >Settings >System >Notifications & actions >Quick actions. Go to Add or remove quick actions and turn on Bluetooth.

    Note: For more info about how to change the apps and settings that appear in action center, see Change notification and action settings in Windows 10.

    To pair a Bluetooth headset, speaker, or other audio device

    1. Turn on your Bluetooth audio device and make it discoverable. The way you make it discoverable depends on the device. Check the device or visit the manufacturer’s website to learn how.
    2. On your PC, select Start >Settings >Devices >Bluetooth & other devices >Add Bluetooth or other device >Bluetooth. Choose the device and follow additional instructions if they appear, then select Done. Your Bluetooth device and PC will usually automatically connect anytime the two devices are in range of each other with Bluetooth turned on.

    To pair a Bluetooth keyboard, mouse, or other device

    1. Turn on your Bluetooth keyboard, mouse, or other device and make it discoverable. The way you make it discoverable depends on the device. Check the device or visit the manufactur’s website to learn how.
    2. On your PC, select Start >Settings >Devices >Bluetooth & other devices >Add Bluetooth or other device >Bluetooth. Choose the device and follow additional instructions if they appear, then select Done.

    To pair a Bluetooth printer or scanner

    1. Turn on your Bluetooth printer or scanner and make it discoverable. The way you make it discoverable depends on the device. Check the device or visit the manufacturer’s website to learn how.
    2. Select Start >Settings >Devices >Printers & scanners >Add a printer or scanner. Wait for it to find nearby printers, then choose the one you want to use and select Add device.

    If you’re having installation issues with your printer or scanner, see either Fix printer problems or Install and use a scanner in Windows 10.

    To pair a Bluetooth device using Swift Pair

    Swift Pair in Windows 10 lets you quickly pair a supported Bluetooth device with your PC. If the Bluetooth device supports Swift Pair, you’ll receive a notification when it’s nearby and you put it into pairing mode to make it discoverable.

    1. Turn on a Bluetooth device that supports Swift Pair and make it discoverable. The way you make it discoverable depends on the device. Check the device or visit the manufacturer’s website to learn more.
    2. If this is your first time using Swift Pair, select Yes when asked if you want to get notifications and use Swift Pair.
    3. When a notification appears that a new Bluetooth device was found, select Connect.
    4. After it’s connected, select Close.

    Tip: If you’re a small business owner looking for more information on how to get Microsoft 365 set up, visit Small business help & learning.

    Источник

    Wireless Noise Canceling Stereo Headset WH-1000XM4

    Press and hold the (power) button for about 2 seconds. You will hear the voice guidance say, “Power on” . Check that the indicator (blue) continues to flash after you release your finger from the button. If the headset has automatically connected to the last connected device, you will hear the voice guidance say, “Bluetooth connected” . Check the connection status on the Bluetooth device. If it is not connected, proceed to step 2.

    As for the operations on your Bluetooth device, refer to the operating instructions supplied with the Bluetooth device. When connected, you will hear the voice guidance say, “Bluetooth connected” .

    Hint

    • The operation above is an example. For more details, refer to the operating instructions supplied with the Bluetooth device.

    Note

    • When connecting, if [ WH-1000XM4 ] and [ LE_WH-1000XM4 ] are displayed, select [ WH-1000XM4 ].
      [ LE_WH-1000XM4 ] will be displayed first, but wait until [ WH-1000XM4 ] is displayed.
      It may take about 30 seconds to 1 minute for [ WH-1000XM4 ] to be displayed.
      If [ WH-1000XM4 ] is not displayed, perform the pairing again.
    • If the last-connected Bluetooth device is placed near the headset, the headset may connect automatically to the device by simply turning on the headset. In that case, deactivate the Bluetooth function on the last-connected device or turn off the power.
    • If you cannot connect your Bluetooth device to the headset, delete the headset pairing information on your Bluetooth device and perform the pairing again. As for the operations on your Bluetooth device, refer to the operating instructions supplied with the Bluetooth device.

    Источник

    Оцените статью
    Adblock
    detector