get Bluetooth Mac Address - Android android.bluetooth

Android examples for android.bluetooth:Bluetooth Address

Description

get Bluetooth Mac Address

Demo Code

import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.content.Intent;
import android.text.TextUtils;
import java.util.Locale;

public class Main{

    public static String getBluetoothMacAddress() {
        BluetoothAdapter bluetoothDefaultAdapter = BluetoothAdapter
                .getDefaultAdapter();//  w  ww.  j  a va 2 s.co  m
        if ((bluetoothDefaultAdapter != null)
                && (bluetoothDefaultAdapter.isEnabled())) {
            String bluetoothMacAddress = BluetoothAdapter
                    .getDefaultAdapter().getAddress();
            return TextUtils.isEmpty(bluetoothMacAddress) ? null
                    : bluetoothMacAddress.replace(":", "").toLowerCase(
                            Locale.US);
        }
        return null;
    }

}

Related Tutorials