当前位置: 首页>>代码示例>>Java>>正文


Java ParcelUuid类代码示例

本文整理汇总了Java中android.os.ParcelUuid的典型用法代码示例。如果您正苦于以下问题:Java ParcelUuid类的具体用法?Java ParcelUuid怎么用?Java ParcelUuid使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ParcelUuid类属于android.os包,在下文中一共展示了ParcelUuid类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: scanLeDevice

import android.os.ParcelUuid; //导入依赖的package包/类
void scanLeDevice(final boolean enable) {
    Timber.d("scanLeDevice enable = " + enable);
    if (enable) {
        mScanning = true;
        List<ScanFilter> filters_v2 = new ArrayList<>();
        ScanFilter scanFilter = new ScanFilter.Builder()
                .setServiceUuid(ParcelUuid.fromString(OWDevice.OnewheelServiceUUID))
                .build();
        filters_v2.add(scanFilter);
        //c03f7c8d-5e96-4a75-b4b6-333d36230365
        mBluetoothLeScanner.startScan(filters_v2, settings, mScanCallback);
    } else {
        mScanning = false;
        mBluetoothLeScanner.stopScan(mScanCallback);
        // added 10/23 to try cleanup
        mBluetoothLeScanner.flushPendingScanResults(mScanCallback);
    }
    mainActivity.invalidateOptionsMenu();
}
 
开发者ID:ponewheel,项目名称:android-ponewheel,代码行数:20,代码来源:BluetoothUtilImpl.java

示例2: startAdvertising

import android.os.ParcelUuid; //导入依赖的package包/类
private void startAdvertising() {
    if (mBluetoothLeAdvertiser == null) return;

    AdvertiseSettings settings = new AdvertiseSettings.Builder()
            .setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED)
            .setConnectable(true)
            .setTimeout(0)
            .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM)
            .build();

    AdvertiseData data = new AdvertiseData.Builder()
            .setIncludeDeviceName(true)
            .setIncludeTxPowerLevel(false)
            .addServiceUuid(new ParcelUuid(GattProfile.SERVICE_UUID))
            .build();

    mBluetoothLeAdvertiser.startAdvertising(settings, data, mAdvertiseCallback);
}
 
开发者ID:holgi-s,项目名称:RangeThings,代码行数:19,代码来源:GattServer.java

示例3: onScanResult

import android.os.ParcelUuid; //导入依赖的package包/类
@Override
public void onScanResult(int callbackType, ScanResult result) {
  super.onScanResult(callbackType, result);
  if (result.getScanRecord() != null) {
    List<ParcelUuid> uuids = result.getScanRecord().getServiceUuids();
    if (uuids != null) {
      for (ParcelUuid uuid : uuids) {
        if (uuid.getUuid().equals(BleService.FIND_ME_SERVICE)) {
          if (!currentAddresses.contains(result.getDevice().getAddress()))
            viewStatePublisher.onNext(
                new NewDevicesViewState.NewDeviceState(
                    result.getDevice().getAddress(),
                    result.getScanRecord().getDeviceName())
            );
          break;
        }
      }
    }
  }
}
 
开发者ID:drfonfon,项目名称:ITagAntiLost,代码行数:21,代码来源:NewDevicePresenter.java

示例4: bind

import android.os.ParcelUuid; //导入依赖的package包/类
@Override public void bind(BluetoothDevice device) {
  nameView.setText(device.getName());
  switch (device.getType()) {
    case DEVICE_TYPE_CLASSIC:
      typeView.setText("DEVICE_TYPE_CLASSIC");
      break;
    case DEVICE_TYPE_DUAL:
      typeView.setText("DEVICE_TYPE_DUAL");
      break;
    case DEVICE_TYPE_LE:
      typeView.setText("DEVICE_TYPE_LE");
      break;
    case DEVICE_TYPE_UNKNOWN:
      typeView.setText("DEVICE_TYPE_UNKNOWN");
      break;
    default:
      typeView.setText("What's this?");
      break;
  }
  addressView.setText(device.getAddress());
  ParcelUuid[] uuids = device.getUuids();
  uuidView.setText(Arrays.toString(uuids));
}
 
开发者ID:shenghaiyang,项目名称:OkBluetooth,代码行数:24,代码来源:DeviceHolder.java

示例5: serializeBluetoothDevice

import android.os.ParcelUuid; //导入依赖的package包/类
public Bundle serializeBluetoothDevice(BluetoothDevice data) {
    Bundle result = new Bundle();
    result.putString("Address", data.getAddress());
    final String bondState =
            MbsEnums.BLUETOOTH_DEVICE_BOND_STATE.getString(data.getBondState());
    result.putString("BondState", bondState);
    result.putString("Name", data.getName());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        String deviceType = MbsEnums.BLUETOOTH_DEVICE_TYPE.getString(data.getType());
        result.putString("DeviceType", deviceType);
        ParcelUuid[] parcelUuids = data.getUuids();
        if (parcelUuids != null) {
            ArrayList<String> uuidStrings = new ArrayList<>(parcelUuids.length);
            for (ParcelUuid parcelUuid : parcelUuids) {
                uuidStrings.add(parcelUuid.getUuid().toString());
            }
            result.putStringArrayList("UUIDs", uuidStrings);
        }
    }
    return result;
}
 
开发者ID:google,项目名称:mobly-bundled-snippets,代码行数:22,代码来源:JsonSerializer.java

示例6: startAdvertising

import android.os.ParcelUuid; //导入依赖的package包/类
private void startAdvertising() {
    BluetoothAdapter bluetoothAdapter = mBluetoothManager.getAdapter();
    mBluetoothLeAdvertiser = bluetoothAdapter.getBluetoothLeAdvertiser();
    if (mBluetoothLeAdvertiser == null) {
        Log.w(TAG, "Failed to create advertiser");
        return;
    }

    AdvertiseSettings settings = new AdvertiseSettings.Builder()
            .setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED)
            .setConnectable(true)
            .setTimeout(0)
            .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM)
            .build();

    AdvertiseData data = new AdvertiseData.Builder()
            .setIncludeDeviceName(true)
            .setIncludeTxPowerLevel(false)
            .addServiceUuid(new ParcelUuid(SERVICE_UUID))
            .build();

    mBluetoothLeAdvertiser
            .startAdvertising(settings, data, mAdvertiseCallback);
}
 
开发者ID:Nilhcem,项目名称:blefun-androidthings,代码行数:25,代码来源:GattServer.java

示例7: startLeScan

import android.os.ParcelUuid; //导入依赖的package包/类
private void startLeScan() {
    mScanning = true;

    ScanSettings settings = new ScanSettings.Builder()
            .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
            .setReportDelay(1000)
            .build();
    List<ScanFilter> filters = new ArrayList<>();
    filters.add(new ScanFilter.Builder().setServiceUuid(new ParcelUuid(SERVICE_UUID)).build());
    mScanner.startScan(filters, settings, mScanCallback);

    // Stops scanning after a pre-defined scan period.
    mStopScanHandler.postDelayed(mStopScanRunnable, SCAN_TIMEOUT_MS);

    invalidateOptionsMenu();
}
 
开发者ID:Nilhcem,项目名称:blefun-androidthings,代码行数:17,代码来源:ScanActivity.java

示例8: matchesServiceUuids

import android.os.ParcelUuid; //导入依赖的package包/类
private boolean matchesServiceUuids(ParcelUuid uuid, ParcelUuid parcelUuidMask,
                                    List<ParcelUuid> uuids) {
    if (uuid == null) {
        return true;
    }
    if (uuids == null) {
        return false;
    }

    for (ParcelUuid parcelUuid : uuids) {
        UUID uuidMask = parcelUuidMask == null ? null : parcelUuidMask.getUuid();
        if (matchesServiceUuid(uuid.getUuid(), uuidMask, parcelUuid.getUuid())) {
            return true;
        }
    }
    return false;
}
 
开发者ID:Twelvelines,项目名称:AndroidMuseumBleManager,代码行数:18,代码来源:ScanFilterCompat.java

示例9: setServiceData

import android.os.ParcelUuid; //导入依赖的package包/类
/**
 * Set partial filter on service data. For any bit in the mask, set it to 1 if it needs to
 * match the one in service data, otherwise set it to 0 to ignore that bit.
 * <p/>
 * The {@code serviceDataMask} must have the same length of the {@code serviceData}.
 *
 * @throws IllegalArgumentException If {@code serviceDataUuid} is null or
 *                                  {@code serviceDataMask} is {@code null} while {@code serviceData} is not or
 *                                  {@code serviceDataMask} and {@code serviceData} has different length.
 */
public Builder setServiceData(ParcelUuid serviceDataUuid,
                              byte[] serviceData, byte[] serviceDataMask) {
    if (serviceDataUuid == null) {
        throw new IllegalArgumentException("serviceDataUuid is null");
    }
    if (mServiceDataMask != null) {
        if (mServiceData == null) {
            throw new IllegalArgumentException(
                    "serviceData is null while serviceDataMask is not null");
        }
        // Since the mServiceDataMask is a bit mask for mServiceData, the lengths of the two
        // byte array need to be the same.
        if (mServiceData.length != mServiceDataMask.length) {
            throw new IllegalArgumentException(
                    "size mismatch for service data and service data mask");
        }
    }
    mServiceDataUuid = serviceDataUuid;
    mServiceData = serviceData;
    mServiceDataMask = serviceDataMask;
    return this;
}
 
开发者ID:Twelvelines,项目名称:AndroidMuseumBleManager,代码行数:33,代码来源:ScanFilterCompat.java

示例10: containsAnyUuid

import android.os.ParcelUuid; //导入依赖的package包/类
/**
 * Returns true if there any common ParcelUuids in uuidA and uuidB.
 *
 * @param uuidA - List of ParcelUuids
 * @param uuidB - List of ParcelUuids
 */
public static boolean containsAnyUuid(ParcelUuid[] uuidA, ParcelUuid[] uuidB) {
    if (uuidA == null && uuidB == null) return true;

    if (uuidA == null) {
        return uuidB.length == 0;
    }

    if (uuidB == null) {
        return uuidA.length == 0;
    }

    HashSet<ParcelUuid> uuidSet = new HashSet<>(Arrays.asList(uuidA));
    for (ParcelUuid uuid : uuidB) {
        if (uuidSet.contains(uuid)) return true;
    }
    return false;
}
 
开发者ID:Twelvelines,项目名称:AndroidMuseumBleManager,代码行数:24,代码来源:BluetoothUuidCompat.java

示例11: containsAllUuids

import android.os.ParcelUuid; //导入依赖的package包/类
/**
 * Returns true if all the ParcelUuids in ParcelUuidB are present in
 * ParcelUuidA
 *
 * @param uuidA - Array of ParcelUuidsA
 * @param uuidB - Array of ParcelUuidsB
 */
public static boolean containsAllUuids(ParcelUuid[] uuidA, ParcelUuid[] uuidB) {
    if (uuidA == null && uuidB == null) return true;

    if (uuidA == null) {
        return uuidB.length == 0;
    }

    if (uuidB == null) return true;

    HashSet<ParcelUuid> uuidSet = new HashSet<>(Arrays.asList(uuidA));
    for (ParcelUuid uuid : uuidB) {
        if (!uuidSet.contains(uuid)) return false;
    }
    return true;
}
 
开发者ID:Twelvelines,项目名称:AndroidMuseumBleManager,代码行数:23,代码来源:BluetoothUuidCompat.java

示例12: startAdvertising

import android.os.ParcelUuid; //导入依赖的package包/类
/**
 * Begin advertising over Bluetooth that this device is connectable
 * and supports the Current Time Service.
 */
private void startAdvertising() {
    BluetoothAdapter bluetoothAdapter = mBluetoothManager.getAdapter();
    mBluetoothLeAdvertiser = bluetoothAdapter.getBluetoothLeAdvertiser();
    if (mBluetoothLeAdvertiser == null) {
        Log.w(TAG, "Failed to create advertiser");
        return;
    }

    AdvertiseSettings settings = new AdvertiseSettings.Builder()
            .setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED)
            .setConnectable(true)
            .setTimeout(0)
            .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM)
            .build();

    AdvertiseData data = new AdvertiseData.Builder()
            .setIncludeDeviceName(true)
            .setIncludeTxPowerLevel(false)
            .addServiceUuid(new ParcelUuid(TimeProfile.TIME_SERVICE))
            .build();

    mBluetoothLeAdvertiser
            .startAdvertising(settings, data, mAdvertiseCallback);
}
 
开发者ID:androidthings,项目名称:sample-bluetooth-le-gattserver,代码行数:29,代码来源:GattServerActivity.java

示例13: startAdvertising

import android.os.ParcelUuid; //导入依赖的package包/类
private void startAdvertising() {
    if (mBluetoothLeAdvertiser == null) return;

    AdvertiseSettings settings = new AdvertiseSettings.Builder()
            .setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED)
            .setConnectable(true)
            .setTimeout(0)
            .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM)
            .build();

    AdvertiseData data = new AdvertiseData.Builder()
            .setIncludeDeviceName(true)
            .addServiceUuid(new ParcelUuid(UARTProfile.UART_SERVICE))
            .build();

    mBluetoothLeAdvertiser.startAdvertising(settings, data, mAdvertiseCallback);
}
 
开发者ID:thejeshgn,项目名称:BleUARTPeripheral,代码行数:18,代码来源:MainActivity.java

示例14: setServiceData

import android.os.ParcelUuid; //导入依赖的package包/类
/**
 * Set partial filter on service data. For any bit in the mask, set it to 1 if it needs to
 * match the one in service data, otherwise set it to 0 to ignore that bit.
 * <p>
 * The {@code serviceDataMask} must have the same length of the {@code serviceData}.
 *
 * @throws IllegalArgumentException If {@code serviceDataUuid} is null or
 *             {@code serviceDataMask} is {@code null} while {@code serviceData} is not or
 *             {@code serviceDataMask} and {@code serviceData} has different length.
 */
public ScanFilter.Builder setServiceData(ParcelUuid serviceDataUuid,
                                                              byte[] serviceData, byte[] serviceDataMask) {
    if (serviceDataUuid == null) {
        throw new IllegalArgumentException("serviceDataUuid is null");
    }
    if (mServiceDataMask != null) {
        if (mServiceData == null) {
            throw new IllegalArgumentException(
                    "serviceData is null while serviceDataMask is not null");
        }
        // Since the mServiceDataMask is a bit mask for mServiceData, the lengths of the two
        // byte array need to be the same.
        if (mServiceData.length != mServiceDataMask.length) {
            throw new IllegalArgumentException(
                    "size mismatch for service data and service data mask");
        }
    }
    mServiceDataUuid = serviceDataUuid;
    mServiceData = serviceData;
    mServiceDataMask = serviceDataMask;
    return this;
}
 
开发者ID:Polidea,项目名称:RxAndroidBle,代码行数:33,代码来源:ScanFilter.java

示例15: for

import android.os.ParcelUuid; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
/*package*/ AdvertiseData getNativeData() {
    AdvertiseData.Builder data = new AdvertiseData.Builder();
    for (UUID id : serviceUuids)
    {
        data.addServiceUuid(new ParcelUuid(id));
    }
    if (m_manufacturerId != 0 && m_manData != null)
    {
        data.addManufacturerData(m_manufacturerId, m_manData);
    }
    if (serviceData != null && serviceData.size() > 0)
    {
        for (UUID dataUuid : serviceData.keySet())
        {
            data.addServiceData(new ParcelUuid(dataUuid), serviceData.get(dataUuid));
        }
    }
    data.setIncludeDeviceName(includeDeviceName());
    data.setIncludeTxPowerLevel(includeTxPowerLevel());
    return data.build();
}
 
开发者ID:AsteroidOS,项目名称:AsteroidOSSync,代码行数:23,代码来源:BleAdvertisingPacket.java


注:本文中的android.os.ParcelUuid类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。