Java tutorial
//package com.java2s; import android.app.Activity; import android.bluetooth.BluetoothAdapter; import android.content.Intent; import android.util.Log; public class Main { public static String deviceMAC; static BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); public static int REQUEST_ENABLE_BT = 1; public static void checkPhoneSettings(Activity activity) { //Check if device supports bluetooth: if (mBluetoothAdapter == null) { //!TODO } else { Log.v("", "Bluetooth is supported"); //Check if bluetooth is enabled. If not, request the user to enable it. if (!mBluetoothAdapter.isEnabled()) { Log.v("", "Bluetooth is not turned on"); Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); activity.startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT); } else { deviceMAC = getMACAddress(); } } } public static String getMACAddress() { if ((mBluetoothAdapter != null) && (mBluetoothAdapter.isEnabled())) { return BluetoothAdapter.getDefaultAdapter().getAddress(); } else return "00000000"; } }