Android tutorial - Android bluetooth list | Android Bluetooth | Android Bluetooth list paired devices example - android app development - android studio - android development tutorial

 bluetooth list paired devices
  • Here is a very simple example that I thought might be helpful to someone. I have included the four files that have content that is key to setting up the application.
  • The program checks to see if the device has bluetooth. If the device does and it isn’t turned on the program will prompt the user to turn it one. Once bluetooth is running it lists the paired devices.
  • The get Bounded Devices() method of Bluetooth Adapter class provides a set containing list of all paired or bounded bluetooth devices.
  • In this example, we are checking if the bluetooth is turned off, if yes then turn it on and list all the paired devices.
  • list android bluetooth device lists
  • Drag one text view from the pallete, now the activity_main.xml file will like this:

File: activity_main.xml

android codes - android tutorial - android sdk
<RelativeLayout xmlns:androclass=""  
    tools:context=".MainActivity" >  
        android:text="Showing Paired Devices:" />  

click below button to copy the code from android tutorial team

Provide Permission

  • You need to provide following permissions in AndroidManifest.xml file.
android codes - android tutorial - android sdk
<uses-permission android:name="android.permission.BLUETOOTH" />  
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />  
click below button to copy the code from android tutorial team
  • The full code of AndroidManifest.xml file is given below.
  • File: AndroidManifest.xml
android codes - android tutorial - android sdk
<?xml version="1.0" encoding="utf-8"?>  
<manifest xmlns:androclass=""  
    android:versionName="1.0" >  
        android:targetSdkVersion="17" />  
    <uses-permission android:name="android.permission.BLUETOOTH" />  
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />  
        android:theme="@style/AppTheme" >  
            android:label="@string/app_name" >  
                <action android:name="android.intent.action.MAIN" />  
                <category android:name="android.intent.category.LAUNCHER" />  

click below button to copy the code from android tutorial team

Activity class

  • Let's write the code to provide the list of paired (bounded) bluetooth devices.
  • File:
android codes - android tutorial - android sdk
package com.example.bluetoothshowpaired;  
import android.os.Bundle;  
import android.view.Menu;  
import java.util.Set;  
import android.bluetooth.BluetoothAdapter;  
import android.bluetooth.BluetoothDevice;  
import android.content.Intent;  
import android.widget.TextView;  
public class MainActivity extends Activity {  
      TextView textview1;  
      private static final int REQUEST_ENABLE_BT = 1;  
      BluetoothAdapter btAdapter;   
      /** Called when the activity is first created. */  
      public void onCreate(Bundle savedInstanceState) {  
        textview1 = (TextView) findViewById(;  
        // Getting the Bluetooth adapter  
        btAdapter = BluetoothAdapter.getDefaultAdapter();  
        textview1.append("\nAdapter: " + btAdapter);  
      /* It is called when an activity completes.*/  
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
        super.onActivityResult(requestCode, resultCode, data);  
        if (requestCode == REQUEST_ENABLE_BT) {  
      protected void onDestroy() {  
      private void CheckBluetoothState() {  
        // Checks for the Bluetooth support and then makes sure it is turned on  
        // If it isn't turned on, request to turn it on  
        // List paired devices  
        if(btAdapter==null) {   
          textview1.append("\nBluetooth NOT supported. Aborting.");  
        } else {  
          if (btAdapter.isEnabled()) {  
            textview1.append("\nBluetooth is enabled...");  
            // Listing paired devices  
            textview1.append("\nPaired Devices are:");  
            Set<BluetoothDevice> devices = btAdapter.getBondedDevices();  
            for (BluetoothDevice device : devices) {  
              textview1.append("\n  Device: " + device.getName() + ", " + device);  
          } else {  
            //Prompt user to turn on Bluetooth  
            Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);  
            startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);  
    public boolean onCreateOptionsMenu(Menu menu) {  
        // Inflate the menu; this adds items to the action bar if it is present.  
        getMenuInflater().inflate(, menu);  
        return true;  

click below button to copy the code from android tutorial team

Related Searches to Android Bluetooth List Paired Devices Example