get Bluetooth Address - Android Bluetooth

Android examples for Bluetooth:Bluetooth Address

Description

get Bluetooth Address

Demo Code


//package com.java2s;
import android.bluetooth.BluetoothAdapter;

public class Main {

    public static String getBluetoothAddress() {
        String address = "";
        try {/*from w w  w  . ja v a2 s .c o  m*/
            BluetoothAdapter bluetoothAdapter = BluetoothAdapter
                    .getDefaultAdapter();
            if (bluetoothAdapter != null && bluetoothAdapter.isEnabled()) {
                address = bluetoothAdapter.getAddress();
            }
        } catch (Exception e) {
            e.printStackTrace();
            return address;
        }
        return address;
    }
}

Related Tutorials