How to connect with bluetooth android

How to pair with bluetooth device in android?

Hello Everyone I am working on Bluetooth and I want to pair my device with the finded bluetooth and connect with the paired bluetooth. I want to know how to do this. And I have also read about client server approach in which we use bluetoothserver socket and bluetooth socket and listenUsingRfcommWithServiceRecord and createRfcommSocketToServiceRecord methods in which we pass mac and uuid. I want to know where we use this approach and how to find the remote device UUId. Thanks in advance.

1 Answer 1

You don’t need to use the mentioned methods, at least for pairing the devices.

Try using Intents to pair. This code might let you get more familiar with Bluetooth.

 public void pairDevice(BluetoothDevice device) < String ACTION_PAIRING_REQUEST = "android.bluetooth.device.action.PAIRING_REQUEST"; Intent intent = new Intent(ACTION_PAIRING_REQUEST); String EXTRA_DEVICE = "android.bluetooth.device.extra.DEVICE"; intent.putExtra(EXTRA_DEVICE, device); String EXTRA_PAIRING_VARIANT = "android.bluetooth.device.extra.PAIRING_VARIANT"; int PAIRING_VARIANT_PIN = 0; intent.putExtra(EXTRA_PAIRING_VARIANT, PAIRING_VARIANT_PIN); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); >Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST); intent.putExtra(EXTRA_DEVICE, device); int PAIRING_VARIANT_PIN = 272; intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, PAIRING_VARIANT_PIN); sendBroadcast(intent); Intent intent = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS); startActivityForResult(intent, REQUEST_PAIR_DEVICE); 

If you want a better approach on how to connect these paired devices, take a look at Bluetooth on AndroidDevelopers:

private class ConnectThread extends Thread < private final BluetoothSocket mmSocket; private final BluetoothDevice mmDevice; public ConnectThread(BluetoothDevice device) < // Use a temporary object that is later assigned to mmSocket, // because mmSocket is final BluetoothSocket tmp = null; mmDevice = device; // Get a BluetoothSocket to connect with the given BluetoothDevice try < // MY_UUID is the app's UUID string, also used by the server code tmp = device.createRfcommSocketToServiceRecord(MY_UUID); >catch (IOException e) < >mmSocket = tmp; > public void run() < // Cancel discovery because it will slow down the connection mBluetoothAdapter.cancelDiscovery(); try < // Connect the device through the socket. This will block // until it succeeds or throws an exception mmSocket.connect(); >catch (IOException connectException) < // Unable to connect; close the socket and get out try < mmSocket.close(); >catch (IOException closeException) < >return; > // Do work to manage the connection (in a separate thread) manageConnectedSocket(mmSocket); > /** Will cancel an in-progress connection, and close the socket */ public void cancel() < try < mmSocket.close(); >catch (IOException e) < >> > 

Источник

Pairing Bluetooth mobile devices in 3 steps

bluetooth_in_mobiles

Nowadays this wireless technology is a common standard that allows us to connect different types of units without any cables or cords. What is Bluetooth used for? It may be used to join a mobile to a car, to join headset to our phone, to use wireless keyboard and mouse with tablet or phone, to act our phone as a modem, to connect mobile to mobile, etc. The average working distance for this technology is not more than about 10 meters so we shouldn’t move connected ones too far from each other.

Читайте также:  Lenovo g560 bluetooth driver

Today the mobiles are very popular. The total count of them is more that people in the world. So we should know how to connect Bluetooth to the phone to stay modern.

The second device type is varied. One of the most popular wireless gadgets for mobile is a headset. Here is a manual on how to connect the Bluetooth headset unit in 4 steps. Another popular option is pairing a phone with car.

The generic main steps are

We don’t need to connect the units again in further. They automatically connect when they are in the range of each other with wireless mode turned on. Note that using modern technology can increase the level of battery utilization, so we should check the charge level on both units regularly.

Turn off the wireless mode just in case of stop usage. Remove each one from a paired list of other one to completely unpair Bluetooth devices if needed.

The most mobiles released after 2007 have this technology onboard. We may always check it through finding an appropriate setting on the one. Below are detailed pairing instructions for different types such as

How to connect Bluetooth on iPhone and iPad#

Ensure that wireless mode is on, do the same on the second unit and tap on its name in the list of available equipment. The user interface is quite the same for iPad by thanks to Apple.

ios_bluetooth_devices_list

Check Bluetooth passkey (or enter it if necessary) and choose “Pair” to accept the connection.

ios_bluetooth_passkey_validation

Now the mobile and the other unit are paired.

Open it details via information icon and choose “Forget this Device” to unpair the device if necessary.

ios_bluetooth_disconnect_device

Attach Bluetooth on Android phone and tablet#

Ensure that wireless technology is on in “Settings\Bluetooth” and tap on the particular available device that must be wirelessly activated too. Repeat search by “Search for devices” or similar if we can’t find a particular unit in the list.

android_bluetooth_devices_list

Check passkey for Bluetooth (or enter it if necessary) and confirm the connection.

android_bluetooth_passkey_validation

Open it details via configuration icon and choose “Unpair” to disconnect the unit. Also, we can set own local name of paired one via “Rename”.

Читайте также:  Изменение настроек блютуз наушников

android_bluetooth_disconnect_device

How to connect Bluetooth on Windows Phone#

Make sure that the mode is on (look at the below picture) and get the list of available ones. The second one should be enabled too. Then find and tap on the second unit name.

windows_phone_bluetooth_devices_list

windows_phone_bluetooth_passkey_validation

Now the mobile and the other unit are paired.

Tap on device in the list and confirm deletion to unpair it in case of no need.

Источник

Подключение Android-смартфонов по Bluetooth

как подключить андроид к андроид через блютуз

По умолчанию функциональность соединения двух Андроид-телефонов невелика – по сути, можно только обмениваться файлами или использовать в комплексе с Wi-Fi и/или NFC для специальных технологий передачи данных (например, HuaweiShare или ShareMe), поэтому покажем процесс соединения именно на примере пересылки документа.

    Первым делом активируйте функцию беспроводной связи – в большинстве современных смартфонов сделать это можно через центр уведомлений. как подключить андроид к андроид через блютуз-1Альтернативный вариант – вызвать «Настройки», затем перейти к беспроводным соединениям, найти в перечне пункт «Bluetooth» и активировать нужный переключатель уже оттуда. Повторите эти же действия для смартфона, к которому нужно подключиться. как подключить андроид к андроид через блютуз-2

  • Далее запустите файловый менеджер – подойдёт любой, даже большинство встроенных. Найдите там файл, который желаете передать, после чего выделите его, откройте контекстное меню (долгим тапом либо нажатием на 3 точки, зависит от приложения) и воспользуйтесь пунктом «Поделиться» (может также называться «Отправить»), после чего укажите вариант «Bluetooth». как подключить андроид к андроид через блютуз-3
  • Откроется экран сопряжённых устройств. Подождите, пока будет обнаружен целевой смартфон, затем тапните по соответствующей ему строке. как подключить андроид к андроид через блютуз-4
  • Далее переходите ко второму телефону и примите на нём передачу. как подключить андроид к андроид через блютуз-5Подождите, пока файл будет передан – ОС уведомит об окончании процедуры. как подключить андроид к андроид через блютуз-6
  • Полученные документы чаще всего сохраняются в память устройства, в папку Bluetooth.
  • как подключить андроид к андроид через блютуз-7

    Как видим, ничего сложного нет. В дальнейшем, когда устройство будет внесено в перечень сопряжённых, к нему для передачи можно будет подключаться одним тапом.

    Источник

    How to Pair a Device Using Bluetooth on Android

    Need to make a Bluetooth connection between your Android phone and another device like speakers, earbuds, or a smartwatch? Here’s how to do it.

    Woman Listening to Music on Bluetooth Headphones

    Readers like you help support MUO. When you make a purchase using links on our site, we may earn an affiliate commission. Read More.

    There’s a good chance that you’ve heard of Bluetooth, a technology to connect nearby devices wirelessly. As an Android user, you would have spotted it in the settings menu on your device.

    You can connect several devices to your Android phone using Bluetooth. It’s easy to pair devices too, as you will find out reading further.

    What Is Bluetooth and What Devices Can You Pair With It?

    Bluetooth is a radio communication technology that lets you connect devices within a short range of each other. It doesn’t use your phone’s Wi-Fi or mobile data for making connections.

    Читайте также:  Gns 3000 gps bluetooth receiver

    Generally, Bluetooth is backward compatible, so the latest Bluetooth 5 devices should be able to pair with devices sporting earlier Bluetooth versions.

    With Bluetooth connectivity, you can enjoy music wirelessly or share files and photos. You can even connect to your car’s infotainment system to enjoy your phone’s playlists or take calls hands-free.

    Infotainment System in Car Showing Bluetooth Message on Screen

    You can connect another phone, a tablet, a Bluetooth speaker, Bluetooth headphones and earbuds, a computer, or an accessory like a fitness band.

    For most Bluetooth devices, the pairing method is similar. Here I will be taking you through the steps on my Android phone. The process on your device might vary but shouldn’t be too different.

    How to Pair and Connect a Bluetooth Device to Your Android Phone

    First, you must turn on Bluetooth on your phone. There are two ways:

    • Swipe down from the top of your screen using two fingers to open Quick Settings. Tap on the Bluetooth B icon to turn it on. Tapping and holding this button will take you to the Bluetooth settings page.
    • Open Settings on your phone and tap on Bluetooth. On the next page, toggle on the button next to Bluetooth.

    The Visible to other devices option should be enabled by default in Advanced Settings. If not, turn it on.

    Turn on Bluetooth in Quick Settings

    Turn On Bluetooth in Bluetooth Settings Page

    Visible to Other Devices Option Enabled in Advanced Settings

    Next, make the Bluetooth device you’re connecting to discoverable—it needs to be in range and visible to your Android phone for successful pairing.

    The pairing process varies with each device, which you will find in the device’s user manual. Some products such as the Amazon Echo also work as Bluetooth speakers and can enter pairing mode by saying, «Alexa, pair.» Others, like a laptop, will require you to match a six-digit pin on both devices.

    On most devices like headphones or speakers, you need to simply press and hold either the power button or the pairing button with the Bluetooth symbol on it. You will either hear a sound briefly or a notification light will flash in pairing mode. Remember that the pairing mode is active only for a short time.

    Pair Your Devices

    Once you’ve done that, you’re able to complete the Bluetooth pairing process.

      Open the Bluetooth Settings page on your phone. By now, your phone will be searching for the Bluetooth devices. This might take some time, but soon you will see names of devices appear under Available Devices.

        If the device you’re trying to pair with doesn’t appear, tap the Refresh button next to Available Devices. Your phone will scan again for devices.

      Источник

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