低功耗蓝牙(BLE)

2023-11-03

https://my.oschina.net/tingzi/blog/215008

   低功耗蓝牙包括的术语及概念:

如上图所示,使用低功耗蓝牙可以包括多个Profile,一个Profile中有多个Service,一个Service中有多个Characteristic,一个Characteristic中包括一个value和多个Descriptor。


Android中进行蓝牙开发需要使用到的类的执行过程是:

1、使用BluetoothAdapter.startLeScan来扫描低功耗蓝牙设备

2、在扫描到设备的回调函数中会得到BluetoothDevice对象,并使用BluetoothAdapter.stopLeScan停止扫描

3、使用BluetoothDevice.connectGatt来获取到BluetoothGatt对象

4、执行BluetoothGatt.discoverServices,这个方法是异步操作,在回调函数onServicesDiscovered中得到status,通过判断status是否等于BluetoothGatt.GATT_SUCCESS来判断查找Service是否成功

5、如果成功了,则通过BluetoothGatt.getService来获取BluetoothGattService

6、接着通过BluetoothGattService.getCharacteristic获取BluetoothGattCharacteristic

7、然后通过BluetoothGattCharacteristic.getDescriptor获取BluetoothGattDescriptor


Android Bluetooth源码静态类图如下:


使用低功耗蓝牙需要用到的权限:

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>

下面介绍怎样使用BLE:

1、准备BLE

    1)获取BluetoothAdapter

     BluetoothAdapter是从系统服务获取到的,全系统就一个。

// Initializes Bluetooth adapter.
final BluetoothManager bluetoothManager =
        (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
mBluetoothAdapter = bluetoothManager.getAdapter();

    2)检测蓝牙是否打开

    如果蓝牙未打开,系统会自动打开,会弹出系统框展示打开蓝牙。

private BluetoothAdapter mBluetoothAdapter;
...
// Ensures Bluetooth is available on the device and it is enabled. If not,
// displays a dialog requesting user permission to enable Bluetooth.
if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled()) {
    Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
    startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}


2、查找BLE设备

   因为扫描BLE设备是电源密集型操作,浪费电量,因此要保证以下原则:

    1)扫描到需要的设备后,马上停止扫描;

    2)给扫描一个时间限制

   扫描示例代码如下:

/**
 * Activity for scanning and displaying available BLE devices.
 */
public class DeviceScanActivity extends ListActivity {

    private BluetoothAdapter mBluetoothAdapter;
    private boolean mScanning;
    private Handler mHandler;

    // Stops scanning after 10 seconds.
    private static final long SCAN_PERIOD = 10000;
    ...
    private void scanLeDevice(final boolean enable) {
        if (enable) {
            // Stops scanning after a pre-defined scan period.
            mHandler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mScanning = false;
                    mBluetoothAdapter.stopLeScan(mLeScanCallback);
                }
            }, SCAN_PERIOD);

            mScanning = true;
            mBluetoothAdapter.startLeScan(mLeScanCallback);
        } else {
            mScanning = false;
            mBluetoothAdapter.stopLeScan(mLeScanCallback);
        }
        ...
    }
...
}

     如果只是要扫描到特定类型的设备,则使用接口 startLeScan(UUID[], BluetoothAdapter.LeScanCallback)通过UUID来查找设备。

    扫描回调的代码如下所示:

private LeDeviceListAdapter mLeDeviceListAdapter;
...
// Device scan callback.
private BluetoothAdapter.LeScanCallback mLeScanCallback =
        new BluetoothAdapter.LeScanCallback() {
    @Override
    public void onLeScan(final BluetoothDevice device, int rssi,             byte[] scanRecord) {
        runOnUiThread(new Runnable() {
           @Override
           public void run() {
               mLeDeviceListAdapter.addDevice(device);
               mLeDeviceListAdapter.notifyDataSetChanged();
           }
       });
   }
};

注意:我们既可以扫描BLE设备,也可以扫描普通蓝牙设备,也可以同时将BLE设备和普通蓝牙设备一起扫描到。


3、连接到GATT Server

   获取到BluetoothGatt实例,

mBluetoothGatt = device.connectGatt(this, false, mGattCallback);

    具体实例如下:

// A service that interacts with the BLE device via the Android BLE API.
public class BluetoothLeService extends Service {
    private final static String TAG = BluetoothLeService.class.getSimpleName();

    private BluetoothManager mBluetoothManager;
    private BluetoothAdapter mBluetoothAdapter;
    private String mBluetoothDeviceAddress;
    private BluetoothGatt mBluetoothGatt;
    private int mConnectionState = STATE_DISCONNECTED;

    private static final int STATE_DISCONNECTED = 0;
    private static final int STATE_CONNECTING = 1;
    private static final int STATE_CONNECTED = 2;

    public final static String ACTION_GATT_CONNECTED =
            "com.example.bluetooth.le.ACTION_GATT_CONNECTED";
    public final static String ACTION_GATT_DISCONNECTED =
            "com.example.bluetooth.le.ACTION_GATT_DISCONNECTED";
    public final static String ACTION_GATT_SERVICES_DISCOVERED =
            "com.example.bluetooth.le.ACTION_GATT_SERVICES_DISCOVERED";
    public final static String ACTION_DATA_AVAILABLE =
            "com.example.bluetooth.le.ACTION_DATA_AVAILABLE";
    public final static String EXTRA_DATA =
            "com.example.bluetooth.le.EXTRA_DATA";

    public final static UUID UUID_HEART_RATE_MEASUREMENT =
            UUID.fromString(SampleGattAttributes.HEART_RATE_MEASUREMENT);

    // Various callback methods defined by the BLE API.
    private final BluetoothGattCallback mGattCallback =
            new BluetoothGattCallback() {
        @Override
        public void onConnectionStateChange(BluetoothGatt gatt, int status,                 int newState) {
            String intentAction;
            if (newState == BluetoothProfile.STATE_CONNECTED) {
                intentAction = ACTION_GATT_CONNECTED;
                mConnectionState = STATE_CONNECTED;
                broadcastUpdate(intentAction);
                Log.i(TAG, "Connected to GATT server.");
                Log.i(TAG, "Attempting to start service discovery:" +
                        mBluetoothGatt.discoverServices());

            } else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
                intentAction = ACTION_GATT_DISCONNECTED;
                mConnectionState = STATE_DISCONNECTED;
                Log.i(TAG, "Disconnected from GATT server.");
                broadcastUpdate(intentAction);
            }
        }

        @Override
        // New services discovered
        public void onServicesDiscovered(BluetoothGatt gatt, int status) {
            if (status == BluetoothGatt.GATT_SUCCESS) {
                broadcastUpdate(ACTION_GATT_SERVICES_DISCOVERED);
            } else {
                Log.w(TAG, "onServicesDiscovered received: " + status);
            }
        }

        @Override
        // Result of a characteristic read operation
        public void onCharacteristicRead(BluetoothGatt gatt,                 BluetoothGattCharacteristic characteristic,                 int status) {
            if (status == BluetoothGatt.GATT_SUCCESS) {
                broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
            }
        }
     ...
    };
...
}

    其中,discoverService方式是异步的,它的回调方法是上面代码中的onServiceDiscovered。

private void broadcastUpdate(final String action) {
    final Intent intent = new Intent(action);
    sendBroadcast(intent);
}

private void broadcastUpdate(final String action,                              final BluetoothGattCharacteristic characteristic) {
    final Intent intent = new Intent(action);

    // This is special handling for the Heart Rate Measurement profile. Data
    // parsing is carried out as per profile specifications.
    if (UUID_HEART_RATE_MEASUREMENT.equals(characteristic.getUuid())) {
        int flag = characteristic.getProperties();
        int format = -1;
        if ((flag & 0x01) != 0) {
            format = BluetoothGattCharacteristic.FORMAT_UINT16;
            Log.d(TAG, "Heart rate format UINT16.");
        } else {
            format = BluetoothGattCharacteristic.FORMAT_UINT8;
            Log.d(TAG, "Heart rate format UINT8.");
        }
        final int heartRate = characteristic.getIntValue(format, 1);
        Log.d(TAG, String.format("Received heart rate: %d", heartRate));
        intent.putExtra(EXTRA_DATA, String.valueOf(heartRate));
    } else {
        // For all other profiles, writes the data formatted in HEX.
        final byte[] data = characteristic.getValue();
        if (data != null && data.length > 0) {
            final StringBuilder stringBuilder = new StringBuilder(data.length);
            for(byte byteChar : data)
                stringBuilder.append(String.format("%02X ", byteChar));
            intent.putExtra(EXTRA_DATA, new String(data) + "\n" +
                    stringBuilder.toString());
        }
    }
    sendBroadcast(intent);
}


// Handles various events fired by the Service.
// ACTION_GATT_CONNECTED: connected to a GATT server.
// ACTION_GATT_DISCONNECTED: disconnected from a GATT server.
// ACTION_GATT_SERVICES_DISCOVERED: discovered GATT services.
// ACTION_DATA_AVAILABLE: received data from the device. This can be a
// result of read or notification operations.
private final BroadcastReceiver mGattUpdateReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        final String action = intent.getAction();
        if (BluetoothLeService.ACTION_GATT_CONNECTED.equals(action)) {
            mConnected = true;
            updateConnectionState(R.string.connected);
            invalidateOptionsMenu();
        } else if (BluetoothLeService.ACTION_GATT_DISCONNECTED.equals(action)) {
            mConnected = false;
            updateConnectionState(R.string.disconnected);
            invalidateOptionsMenu();
            clearUI();
        } else if (BluetoothLeService.
                ACTION_GATT_SERVICES_DISCOVERED.equals(action)) {
            // Show all the supported services and characteristics on the
            // user interface.
            displayGattServices(mBluetoothLeService.getSupportedGattServices());
        } else if (BluetoothLeService.ACTION_DATA_AVAILABLE.equals(action)) {
            displayData(intent.getStringExtra(BluetoothLeService.EXTRA_DATA));
        }
    }
};


4、读BLE属性

    一旦获取到GATT的Services,就可以读写他们的属性了,实例如下:

public class DeviceControlActivity extends Activity {
    ...
    // Demonstrates how to iterate through the supported GATT
    // Services/Characteristics.
    // In this sample, we populate the data structure that is bound to the
    // ExpandableListView on the UI.
    private void displayGattServices(List<BluetoothGattService> gattServices) {
        if (gattServices == nullreturn;
        String uuid = null;
        String unknownServiceString = getResources().
                getString(R.string.unknown_service);
        String unknownCharaString = getResources().
                getString(R.string.unknown_characteristic);
        ArrayList<HashMap<StringString>> gattServiceData =
                new ArrayList<HashMap<StringString>>();
        ArrayList<ArrayList<HashMap<StringString>>> gattCharacteristicData
                = new ArrayList<ArrayList<HashMap<StringString>>>();
        mGattCharacteristics =
                new ArrayList<ArrayList<BluetoothGattCharacteristic>>();

        // Loops through available GATT Services.
        for (BluetoothGattService gattService : gattServices) {
            HashMap<StringString> currentServiceData =
                    new HashMap<StringString>();
            uuid = gattService.getUuid().toString();
            currentServiceData.put(
                    LIST_NAME, SampleGattAttributes.
                            lookup(uuid, unknownServiceString));
            currentServiceData.put(LIST_UUID, uuid);
            gattServiceData.add(currentServiceData);

            ArrayList<HashMap<StringString>> gattCharacteristicGroupData =
                    new ArrayList<HashMap<StringString>>();
            List<BluetoothGattCharacteristic> gattCharacteristics =
                    gattService.getCharacteristics();
            ArrayList<BluetoothGattCharacteristic> charas =
                    new ArrayList<BluetoothGattCharacteristic>();
           // Loops through available Characteristics.
            for (BluetoothGattCharacteristic gattCharacteristic :
                    gattCharacteristics) {
                charas.add(gattCharacteristic);
                HashMap<StringString> currentCharaData =
                        new HashMap<StringString>();
                uuid = gattCharacteristic.getUuid().toString();
                currentCharaData.put(
                        LIST_NAME, SampleGattAttributes.lookup(uuid,
                                unknownCharaString));
                currentCharaData.put(LIST_UUID, uuid);
                gattCharacteristicGroupData.add(currentCharaData);
            }
            mGattCharacteristics.add(charas);
            gattCharacteristicData.add(gattCharacteristicGroupData);
         }
    ...
    }
...
}

  在获取Service的时候,每个蓝牙设备都会有两个默认的Service,它们和对应的UUID分别如下:

Bluetooth Generic Access Profile    {00001800-0000-1000-8000-00805f9b34fb}

Bluetooth Generic Attribute Profile {00001801-0000-1000-8000-00805F9B34FB}


5、收到GATT通知

   如果设备主动给手机发信息,则可以通过notification的方式,这种方式不用手机去轮询地读设备上的数据。手机可以用如下方式给设备设置notification功能。

private BluetoothGatt mBluetoothGatt;
BluetoothGattCharacteristic characteristic;
boolean enabled;
...
mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);
...
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(
        UUID.fromString(SampleGattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mBluetoothGatt.writeDescriptor(descriptor);

    如果notificaiton方式对于某个Characteristic是enable的,那么当设备上的这个Characteristic改变时,手机上的onCharacteristicChanged() 回调就会被促发。如下所示:

@Override
// Characteristic notification
public void onCharacteristicChanged(BluetoothGatt gatt,         BluetoothGattCharacteristic characteristic) {
    broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
}

6、关闭客户端蓝牙

public void close() {
    if (mBluetoothGatt == null) {
        return;
    }
    mBluetoothGatt.close();
    mBluetoothGatt = null;
}



本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

低功耗蓝牙(BLE) 的相关文章

  • App 和设备通过蓝牙连接收发数据

    一 Android 中进行蓝牙开发需要用到的类和执行过程 1 使用BluetoothAdapter startLeScance来扫描设备 2 在扫描到设备的回调函数中的得到BluetoothDevice 对象 并使用Bluetooth st
  • nRF52832学习记录(四、定时器)

    一 nRF52832 定时器基本介绍 nRF52832 包含了 5个定时器模块 定时器有着不同的位宽选择 8 16 24 32位 通过BITMODE 寄存器的 第 0 1 位 选择 nRF52832 的定时器的内部结构 1 时钟源 定时器工
  • Android 蓝牙 hfp音频连接

    Android 蓝牙 hfp音频连接 1 连接音频 2 音频连接状态 该文章基于Android Q 1 连接音频 在手机音频正常连接时 接通电话 点选蓝牙通话 mDeviceManager connectAudio返回true 如果是之前默
  • 蓝牙之九-AT命令

    AT命令用于HF协议 该命令使参考3GPP 27 007协议 以下是HFP规范 每个命令行只有一个命令 AG侧默认不回显命令 AG使用冗长的格式返回结果 以下字符将被用于AT命令和返回结果格式中
  • BLE 蓝牙的一些心得总结

    1 TI 的CC2541协议栈开发教程 https blog csdn net feilusia category 5630377 html 2 以下是我对BLE 蓝牙的一些理解 如果有什么不对的地方 恳请大佬们指点
  • 蓝牙mesh组网-JDY-24M初步探索

    操作步骤如下 这款JDY 24M蓝牙功能强大 我主要应用其中mesh组网这个功能 mesh组网简单来说 就是组网的这几个蓝牙是可以互相通信 一一通信是通过蓝牙地址来确定的 一 配置组网 需要用到两根USB转TTL的线 JDY 24M蓝牙2个
  • ESP-NOW无线通信

    本文由铁熊与默联合创作 在学习 Arduino 开发的过程中 无线通讯是我们学习道路上一道必过的坎 无线通讯摆脱了线材的束缚 使用更加灵活且通讯距离根据不同无线模块可达几十米甚至是数公里 常见的无线通讯方式有蓝牙 WiFi LoRa NB
  • JDY-31蓝牙模块使用指南

    前言 本来是想买个hc 05 这种非常常用的模块 但是在优信电子买的时候 说有个可以替代的 没注意看 买回来折腾半天 这个模块是从机模块 蓝牙模块分为主机从机和主从一体的 主机与从机的区别就是 主机可以主动连接从机 但是从机不能主动连接主机
  • 使用蓝牙耳机听群晖ds218play中的音乐(audio station)

    缘起 有时需要欣赏nas中的音乐而又不影响家人 有什么方法呢 思路 研究了一下 发现新版的群晖dms支持蓝牙usb蓝牙适配器 可以使用audio station播放 蓝牙耳机收听 步骤 1 购买CSR USB蓝牙适配器 2 插入ds218p
  • Android 蓝牙串口通信Demo

    目录 一 前言 二 效果图 三 源码 带注释 1 布局代码 2 Java代码 3 权限声明 四 注意 五 项目源码下载 一 前言 在学校和机电的同学组队准备做一个智能小车去参加比赛 需要我开发一个小车的控制app 所以我开始学习蓝牙串口通信
  • Bluetooth 蓝牙介绍(七):逻辑链路控制和适配协议规范(L2cap 协议)

    文章目录 前言 L2CAP 特性 前提 术语 常规操作 通道标识符 操作模式 数据包格式 CONNECTION ORIENTED CHANNELS IN BASIC L2CAP MODE CONNECTIONLESS DATA CHANNE
  • BLE MESH组网(五)配置BLE MESH

    BLE MESH 五 配置BLE MESH 前言 概述 配置协议 供应程序 信标 邀请 交换公钥 前言 2017 年 5 月 全球最臭名昭著的勒索软件 WannaCry 在全球范围内积极攻击计算机 劫持用户数据索要赎金 这次攻击影响了 15
  • bluez调试笔记

    蓝牙系列 bluez调试笔记 weixin 41069709的博客 CSDN博客 bluezbluez移植https blog csdn net weixin 41069709 article details 125168114 spm 1
  • BES2300x笔记----TWS组对与蓝牙配对

    https me csdn net zhanghuaishu0 一 前言 看到有 道友 在评论区留言 对TWS组对 BT配对以及回连流程部分很迷糊 那这第二篇我们就来说说BES平台的相关流程和接口 PS 蓝牙基础部分就不再赘述了 网上有很多
  • 蓝牙解析(part7):BLE的连接

    转自Wowo大神的http www wowotech net bluetooth ble connection html 1 前言 了解蓝牙的人都知道 在经典蓝牙中 保持连接 Connection 是一个相当消耗资源 power和带宽 的过
  • 蓝牙之十八- bluetooth pair

    蓝牙之十八 bluetooth pair 在蓝牙核心规范2 1之后 蓝牙配对除了传统的PIN Code Pairing方式外 新增了Secure Simple Pairing配对方式 根据核心规范4 2 简单配对主要有两种目的 蓝牙配对过程
  • 【转载】浅谈蓝牙 Mesh 组网技术

    本文转载自 Eren https www erenship com posts 63c7 html 蓝牙技术联盟官方网址 https www bluetooth com zh cn 蓝牙技术联盟公众号 BluetoothSIG 蓝牙技术联盟
  • 蓝牙协议规范--L2CAP

    L2CAP 分析 记住一点 软件和硬件分开理解 数据经由物理通道交互 上层通道由各层协议打通 L2CAP 全称为逻辑链路控制与适配协议 Logical Link Control and Adaptation Protocol 位于基带层之上
  • 蓝牙设备中的Device UUID 与 Service UUID

    Device UUID也可以被称作为DeviceID Android 设备上扫描获取到的 deviceId 为外围设备的 MAC 地址 相对固定 iOS 设备上扫描获取到的 deviceId 是系统根据外围设备 MAC 地址及发现设备的时间
  • android bluetooth UUID蓝牙查询表

    UUID是 Universally Unique Identifier 的简称 通用唯一识别码的意思 对于蓝牙设备 每个服务都有通用 独立 唯一的UUID与之对应 也就是说 在同一时间 同一地点 不可能有两个相同的UUID标识的不同服务 以

随机推荐

  • flask.ext 的那些事

    偶然发现 在pycharm 使用alter enter 自动修复 未导入的外部模块时 推荐的是 flask ext 包名 的形式 如下例 from flask ext migrate import Migrate MigrateComman
  • 分立元件搭建自举电路解析-高端mos驱动

    分立元件搭建自举电路 上桥mos驱动 高端MOS为什么要自举电路 自举电容 分立元件搭建自举电路 高端MOS为什么要自举电路 众所周知MOS是电压型驱动 只有G极比S极高一个开启电压Vth之后 MOS才会导通 这里指NMOS 但是如下图 我
  • JQuery 页面加载完成后执行事件

    一 document ready function code 二 jQuery document ready function code 三 window nl ad function code 四 将jquery代码放入body的后面 这
  • 使用OpenCV/python进行双目测距

    在做SLAM时 希望用到深度图来辅助生成场景 所以要构建立体视觉 在这里使用OpenCV的Stereo库和python来进行双目立体视觉的图像处理 立体标定 应用标定数据 转换成深度图 标定 在开始之前 需要准备的当然是两个摄相头 根据你的
  • 什么是 agent

    agent 是任何通过sensor感知其环境并通过actuators在此环境中作出行动的东西 比如人agent sensor 是眼睛 耳朵 以及其他器官 actuators 是手 腿 声道等 比如机器人agent sensor 是摄像头 红
  • JVM系列-第8章-执行引擎

    文章目录 toc 执行引擎 执行引擎概述 执行引擎概述 执行引擎工作过程 Java代码编译和执行过程 解释执行和即时编译 什么是解释器 什么是JIT编译器 机器码 指令 汇编语言 机器码 指令和指令集 汇编语言 高级语言 字节码 C C 源
  • Java使用图片压缩工具压缩图片的两种方法

    上代码 pom xml
  • 单元测试是什么?为什么要做单元测试?

    背锅侠 一个有个性的订阅号 1 单元测试是什么 单元测试是开发者编写的一小段代码 用于检验被测代码的一个很小的 很明确的功能是否正确 通常而言 一个单元测试是用于判断某个特定条件 或者场景 下某个特定函数的行为1 长按图片识别二维码 入群
  • [Qt 教程之Widgets模块] —— QButtonGroup抽象容器

    Qt系列教程总目录 文章目录 0 QButtonGroup简介 1 创建QButtonGroup 2 成员函数与信号 3 示例 3 1 为按钮组添加按钮 3 2 为按钮设置id 3 3 按钮组中按钮的互斥状态 3 4 获取组内所有按钮 3
  • 开源图像和视频编辑软件汇总

    1 Belender http www blender org Blender 是一套 三维绘图 及 渲染 软件 它具有跨平台的特性 支持 FreeBSD IRIX GNU Linux Microsoft Windows Mac OS X
  • django自带的序列化组件

    目录 sweetalert前端插件 django自带的序列化组件 简易分页器 带有页码的分页器 优化后的版本 模块代码 后端代码 Forms组件 校验数据 渲染标签 展示信息 widgets 注意 sweetalert前端插件 https
  • 计算机组成原理 及CPU,硬盘,内存三者的关系

    电脑之父 冯 诺伊曼 提出了组成计算机的五大部件 输入设备 输出设备 存储器 运算器和控制器 下图为 现在我们电脑的 键盘鼠标 显示器 机箱 音响等等 这里显示器为比较老的CRT显示器 现在一般都成功了液晶显示器 回想一下 在玩电脑的时候
  • chromium-cronet库的编译用于Android和ios平台实现quic协议

    chromium cronet文档 原文文档写的已经很清楚 最好还是参考官方文档 避免由于版本原因导致的问题 Cronet开发者文档 https developer android com guide topics connectivity
  • oracle学习之路(6)oracle下载地址

    ocacle下载地址 https www oracle com database technologies ocacle19c版本下载地址https www oracle com database technologies oracle d
  • flutter项目中使用

    一些小部件 GestureDetector 手势 手势表示由一个或多个指针移动组成的动作 主要有以下几种 onTap 点击事件触发 Divider 设置分割线 SharedPreferences数据存储 SharedPreferences
  • java后端分享整理

    java规范总结 1 Java 常见的代码规范 1 1 Java 自带的工具方法 1 1 1 比较两个对象是否相等 1 1 2 apache commons工具类库 1 1 2 1 字符串判空 1 1 2 3 重复拼接字符串 1 1 2 4
  • 图形放大效果

  • 近日总结

    P1149 火柴棒等式 题目描述 给你n根火柴棍 你可以拼出多少个形如 A B CA B CA B C 的等式 等式中的AAA BBB CCC是用火柴棍拼出的整数 若该数非零 则最高位不能是000 用火柴棍拼数字0 90 90 9的拼法如图
  • version `GLIBCXX_3.4.20‘ not found

    问题描述 编译产生如下错误 问题原因 如下图所示 usr lib x86 64 linux gnu libstdc so 6没有GLIBCXX 3 4 20 strings usr lib x86 64 linux gnu libstdc
  • 低功耗蓝牙(BLE)

    https my oschina net tingzi blog 215008 低功耗蓝牙包括的术语及概念 如上图所示 使用低功耗蓝牙可以包括多个Profile 一个Profile中有多个Service 一个Service中有多个Chara