Я занимаюсь разработкой приложения для Android для полноценного общения.
Мой вопрос, почему функция
public BluetoothGatt connectGatt(Context context, boolean autoConnect,BluetoothGattCallback callback, int transport)
требует 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 is not supported
return null;
}
BluetoothGatt gatt = new BluetoothGatt(iGatt, this, transport, opportunistic, phy);
gatt.connect(autoConnect, callback, handler);
return gatt;
} catch (RemoteException e) {Log.e(TAG, "", e);}
return null;
}
Странно то, что это свойство не помечено как устаревшее.
Я попытался передать нуль вместо контекста и кажется, что он работает нормально () с контекстом или без.
Кто-нибудь знает, почему это там?