get Bluetooth Paired Devices - Android Bluetooth

Android examples for Bluetooth:Bluetooth Bond

Description

get Bluetooth Paired Devices

Demo Code


//package com.java2s;

import java.util.ArrayList;

import java.util.Set;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;

public class Main {
    public static ArrayList<BluetoothDevice> getPairedDevices() {
        Set<BluetoothDevice> pairedDevice = BluetoothAdapter
                .getDefaultAdapter().getBondedDevices();
        ArrayList<BluetoothDevice> arrayListPairedBluetoothDevices = new ArrayList<BluetoothDevice>();
        if (pairedDevice != null && pairedDevice.size() > 0) {
            for (BluetoothDevice device : pairedDevice) {
                arrayListPairedBluetoothDevices.add(device);
            }//from   ww w .  j a  v  a 2  s .c  o m
        }
        return arrayListPairedBluetoothDevices;
    }
}

Related Tutorials