本文整理汇总了Java中android.bluetooth.BluetoothAdapter.checkBluetoothAddress方法的典型用法代码示例。如果您正苦于以下问题:Java BluetoothAdapter.checkBluetoothAddress方法的具体用法?Java BluetoothAdapter.checkBluetoothAddress怎么用?Java BluetoothAdapter.checkBluetoothAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.bluetooth.BluetoothAdapter
的用法示例。
在下文中一共展示了BluetoothAdapter.checkBluetoothAddress方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connect
import android.bluetooth.BluetoothAdapter; //导入方法依赖的package包/类
@ReactMethod
public void connect(String peripheralUUID, Callback callback) {
Log.d(LOG_TAG, "Connect to: " + peripheralUUID );
synchronized(peripherals) {
Peripheral peripheral = peripherals.get(peripheralUUID);
Log.e(LOG_TAG, "peripheral " + peripheral);
if (peripheral == null) {
if (peripheralUUID != null) {
peripheralUUID = peripheralUUID.toUpperCase();
}
if (BluetoothAdapter.checkBluetoothAddress(peripheralUUID)) {
BluetoothDevice device = bluetoothAdapter.getRemoteDevice(peripheralUUID);
peripheral = new Peripheral(device, reactContext);
peripherals.put(peripheralUUID, peripheral);
} else {
callback.invoke("Invalid peripheral uuid");
return;
}
}
peripheral.connect(callback, reactContext!=null?getCurrentActivity():context);
}
}
示例2: isValidBluetoothAddress
import android.bluetooth.BluetoothAdapter; //导入方法依赖的package包/类
private static boolean isValidBluetoothAddress(String address) {
return !StringUtils.isNullOrEmpty(address)
&& BluetoothAdapter.checkBluetoothAddress(address)
&& !address.equals(FAKE_BLUETOOTH_ADDRESS);
}
示例3: setDeviceAddress
import android.bluetooth.BluetoothAdapter; //导入方法依赖的package包/类
/**
* Set filter on device address.
*
* @param deviceAddress The device Bluetooth address for the filter. It needs to be in the
* format of "01:02:03:AB:CD:EF". The device address can be validated using
* {@link BluetoothAdapter#checkBluetoothAddress}.
* @throws IllegalArgumentException If the {@code deviceAddress} is invalid.
*/
public Builder setDeviceAddress(String deviceAddress) {
if (deviceAddress != null && !BluetoothAdapter.checkBluetoothAddress(deviceAddress)) {
throw new IllegalArgumentException("invalid device address " + deviceAddress);
}
mDeviceAddress = deviceAddress;
return this;
}
示例4: addDeviceAddress
import android.bluetooth.BluetoothAdapter; //导入方法依赖的package包/类
/**
* Add a MAC address to the filter list and enables filtering of events by device MAC address.
*
* @param address device mac address. If the address is not valid {@link IllegalArgumentException}
* will be thrown.
*
* @return this builder instance.
*/
public ScanBuilder addDeviceAddress(String address) {
if (!BluetoothAdapter.checkBluetoothAddress(address)) {
throw new IllegalArgumentException("Invalid address:" + address);
}
scannerConfiguration.addDeviceAddress(address);
return null;
}
示例5: isMacValid
import android.bluetooth.BluetoothAdapter; //导入方法依赖的package包/类
/**
* Validates a MAC address.
*
* @param mac the mac address to validate
* @return true if it's a valid address, otherwise false
*/
public static boolean isMacValid(@NonNull String mac) {
return BluetoothAdapter.checkBluetoothAddress(mac.toUpperCase());
}