import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.Intent;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.UUID;
public class BluetoothUtil {
/**
* 蓝牙是否打开
*/
public static boolean isBluetoothOn() {
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter != null)
// 蓝牙已打开
if (mBluetoothAdapter.isEnabled())
return true;
return false;
}
/**
* 获取所有已配对的设备
*/
public static List<BluetoothDevice> getPairedDevices() {
List deviceList = new ArrayList<>();
Set<BluetoothDevice> pairedDevices = BluetoothAdapter.getDefaultAdapter().getBondedDevices();
if (pairedDevices.size() &