Java tutorial
//package com.java2s; //License from project: Open Source License import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothManager; import android.content.Context; public class Main { public static BluetoothAdapter getBluetoothAdapter(Context context) { // Initializes a Bluetooth adapter. For API level 18 and above, get a reference to // BluetoothAdapter through BluetoothManager. final BluetoothManager bluetoothManager = (BluetoothManager) context .getSystemService(Context.BLUETOOTH_SERVICE); if (bluetoothManager == null) { return null; } return bluetoothManager.getAdapter(); } }