Code example for BluetoothAdapter

Methods: getBondedDevices, isEnabled

0
     * 
     * @return a list of all discovered and bonded devices 
     * @throws IllegalStateException if Bluetooth is not enabled 
     */ 
    public List<BluetoothDevice> getAllDevices() {
        if (!mBluetoothAdapter.isEnabled())
            throw new IllegalStateException("Bluetooth must be enabled");
        List<BluetoothDevice> allDevices = new ArrayList<BluetoothDevice>(mDiscoveredDevices);
        allDevices.addAll(mBluetoothAdapter.getBondedDevices());
        return allDevices;
    } 
 
    /** 
     * Accessor for bonded devices 
     * 
     * @return a list of all bonded devices 
     * @throws IllegalStateException if Bluetooth is not enabled 
     */ 
    public List<BluetoothDevice> getBondedDevices() {
        if (!mBluetoothAdapter.isEnabled())
            throw new IllegalStateException("Bluetooth must be enabled");