小编Mak*_*kov的帖子

为什么 Android BluetoothDevice.conenctGatt 如果不使用它需要上下文

我正在开发用于 ble 通信的 android 应用程序。

我的问题是为什么这个函数

public BluetoothGatt connectGatt(Context context, boolean autoConnect,BluetoothGattCallback callback, int transport)
Run Code Online (Sandbox Code Playgroud)

需要Context作为参数,我挖掘了函数,发现它没有在任何地方使用它,正如你在这里看到的:

public BluetoothGatt connectGatt(Context context, boolean autoConnect,
                                     BluetoothGattCallback callback, int transport,
                                     boolean opportunistic, int phy, Handler handler) {
        if (callback == null)
            throw new NullPointerException("callback is null");

        // TODO(Bluetooth) check whether platform support BLE
        //     Do the check here or in GattServer?
        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
        IBluetoothManager managerService = adapter.getBluetoothManager();
        try {
            IBluetoothGatt iGatt = managerService.getBluetoothGatt();
            if (iGatt == null) {
                // BLE …
Run Code Online (Sandbox Code Playgroud)

android bluetooth-lowenergy

3
推荐指数
1
解决办法
528
查看次数

标签 统计

android ×1

bluetooth-lowenergy ×1