zoukankan      html  css  js  c++  java
  • Android:获取本机已配对蓝牙列表

    1. AndroidManifest.xml 配置文件中加入蓝牙许可权限:  <uses-permission android:name="android.permission.BLUETOOTH"/>

               BluetoothAdapter bluetoothAdapter =BluetoothAdapter.getDefaultAdapter();
    if(bluetoothAdapter == null) { System.out.println("本机未发现蓝牙设备。"); }else { if(!bluetoothAdapter.isEnabled())//判断蓝牙设备是否已开起 { //开起蓝牙设备 Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivity(intent); } Set<BluetoothDevice> devices = bluetoothAdapter.getBondedDevices(); for(Iterator<BluetoothDevice> iterator = devices.iterator();iterator.hasNext();) { BluetoothDevice device = iterator.next(); System.out.println(device.getAddress()); } }
  • 相关阅读:
    有一个双重模板化的错误实现
    非类型模板参数
    C++模板
    初始化列表initializer_list
    C++类型转换
    const引用和constexpr
    逆元
    卡特兰数
    最短路问题
    Android打印机效果的闪屏
  • 原文地址:https://www.cnblogs.com/you000/p/2809093.html
Copyright © 2011-2022 走看看