本文整理匯總了Java中android.bluetooth.le.ScanFilter.Builder方法的典型用法代碼示例。如果您正苦於以下問題:Java ScanFilter.Builder方法的具體用法?Java ScanFilter.Builder怎麽用?Java ScanFilter.Builder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.bluetooth.le.ScanFilter
的用法示例。
在下文中一共展示了ScanFilter.Builder方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: toApi21
import android.bluetooth.le.ScanFilter; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public ScanFilter toApi21() {
ScanFilter.Builder builder = new ScanFilter.Builder();
if (mDeviceName != null) {
builder.setDeviceName(mDeviceName);
}
if (mServiceUuid != null) {
builder.setServiceUuid(mServiceUuid, mServiceUuidMask);
}
if (mDeviceAddress != null) {
builder.setDeviceAddress(mDeviceAddress);
}
if (mServiceDataUuid != null) {
builder.setServiceData(mServiceDataUuid, mServiceData, mServiceDataMask);
}
if (mManufacturerId < 0) {
builder.setManufacturerData(mManufacturerId, mManufacturerData, mManufacturerDataMask);
}
return builder.build();
}
示例2: scanDevice
import android.bluetooth.le.ScanFilter; //導入方法依賴的package包/類
protected static void scanDevice(BluetoothAdapter bluetoothAdapter, U2FBLEDeviceNotification notification, Logger logger, Context context, String data, ScanType scanType) {
BluetoothLeScanner bluetoothScanner = bluetoothAdapter.getBluetoothLeScanner();
ScanFilter.Builder builder = new ScanFilter.Builder();
switch(scanType) {
case SCAN_BY_NAME:
builder.setDeviceName(data);
break;
}
Vector<ScanFilter> filter = new Vector<ScanFilter>();
filter.add(builder.build());
ScanSettings.Builder builderScanSettings = new ScanSettings.Builder();
builderScanSettings.setScanMode(ScanSettings.SCAN_MODE_BALANCED);
builderScanSettings.setReportDelay(0);
LocalScanCallback scannerCallback = new LocalScanCallback(bluetoothAdapter, logger, notification, context);
bluetoothScanner.startScan(filter, builderScanSettings.build(), scannerCallback);
}
示例3: toApi21
import android.bluetooth.le.ScanFilter; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
ScanFilter toApi21() {
ScanFilter.Builder builder = new ScanFilter.Builder();
if (mDeviceName != null) {
builder.setDeviceName(mDeviceName);
}
if (mServiceUuid != null) {
builder.setServiceUuid(mServiceUuid, mServiceUuidMask);
}
if (mDeviceAddress != null) {
builder.setDeviceAddress(mDeviceAddress);
}
if (mServiceDataUuid != null) {
builder.setServiceData(mServiceDataUuid, mServiceData, mServiceDataMask);
}
if (mManufacturerId < 0) {
builder.setManufacturerData(mManufacturerId, mManufacturerData, mManufacturerDataMask);
}
return builder.build();
}
示例4: getScanFilter
import android.bluetooth.le.ScanFilter; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static List<ScanFilter> getScanFilter() {
ScanFilter.Builder builder =
new ScanFilter.Builder();
builder.setServiceUuid(new ParcelUuid(TappyVersions.VersionOne.TRUCONNECT_SERVICE_UUID));
List<ScanFilter> list = new ArrayList<ScanFilter>(1);
list.add(builder.build());
return list;
}
示例5: startScan
import android.bluetooth.le.ScanFilter; //導入方法依賴的package包/類
private void startScan() {
BluetoothLeScanner bluetoothScanner = bluetoothAdapter.getBluetoothLeScanner();
ScanFilter.Builder builder = new ScanFilter.Builder();
Vector<ScanFilter> filter = new Vector<ScanFilter>();
filter.add(builder.build());
ScanSettings.Builder builderScanSettings = new ScanSettings.Builder();
builderScanSettings.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY);
builderScanSettings.setReportDelay(0);
bluetoothScanner.startScan(filter, builderScanSettings.build(), leScanCallback);
}
示例6: createScanFilters
import android.bluetooth.le.ScanFilter; //導入方法依賴的package包/類
private List<ScanFilter> createScanFilters() {
ScanFilter.Builder builder = new ScanFilter.Builder();
builder.setServiceUuid(new ParcelUuid(serviceUUID));
ArrayList<ScanFilter> scanFilters = new ArrayList<>();
scanFilters.add(builder.build());
return scanFilters;
}
示例7: Ble
import android.bluetooth.le.ScanFilter; //導入方法依賴的package包/類
public Ble(Context c, BleListener i, String deviceUuid, String r, String t)
{
context = c;
iface = i;
superPanelUuid = ParcelUuid.fromString(deviceUuid);
rxUUid = UUID.fromString(r);
txUUid = UUID.fromString(t);
adapter = BluetoothAdapter.getDefaultAdapter();
scanner = adapter.getBluetoothLeScanner();
ScanFilter.Builder filter = new ScanFilter.Builder();
filter.setServiceUuid(superPanelUuid);
ScanFilter.Builder superPanelFilter = new ScanFilter.Builder();
superPanelFilter.setServiceUuid(superPanelUuid);
ScanSettings.Builder settings = new ScanSettings.Builder();
settings.setScanMode(ScanSettings.SCAN_MODE_LOW_POWER);
List<ScanFilter> filters = new ArrayList<ScanFilter>();
filters.add(filter.build());
//filters.add(superPanelFilter.build());
if(scanner == null)
{
System.out.println("Failed to get LE scanner");
return;
}
scanner.startScan(filters, settings.build(), scanCallback);
}
示例8: buildScanFilters
import android.bluetooth.le.ScanFilter; //導入方法依賴的package包/類
private List<ScanFilter> buildScanFilters() {
List<ScanFilter> scanFilters = new ArrayList<>();
ScanFilter.Builder builder = new ScanFilter.Builder();
for(int i = 0; i < this.serviceUuids.size(); i++){
builder.setServiceUuid(ParcelUuid.fromString(this.serviceUuids.getString(i)));
}
scanFilters.add(builder.build());
return scanFilters;
}
示例9: createScanFiltersForBeaconParsers
import android.bluetooth.le.ScanFilter; //導入方法依賴的package包/類
public List<ScanFilter> createScanFiltersForBeaconParsers(List<BeaconParser> beaconParsers) {
List<ScanFilter> scanFilters = new ArrayList<ScanFilter>();
// for each beacon parser, make a filter expression that includes all its desired
// hardware manufacturers
for (BeaconParser beaconParser: beaconParsers) {
List<ScanFilterData> sfds = createScanFilterDataForBeaconParser(beaconParser);
for (ScanFilterData sfd: sfds) {
ScanFilter.Builder builder = new ScanFilter.Builder();
if (sfd.serviceUuid != null) {
// Use a 16 bit service UUID in a 128 bit form
String serviceUuidString = String.format("0000%04X-0000-1000-8000-00805f9b34fb", sfd.serviceUuid);
String serviceUuidMaskString = "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF";
ParcelUuid parcelUuid = ParcelUuid.fromString(serviceUuidString);
ParcelUuid parcelUuidMask = ParcelUuid.fromString(serviceUuidMaskString);
if (LogManager.isVerboseLoggingEnabled()) {
LogManager.d(TAG, "making scan filter for service: "+serviceUuidString+" "+parcelUuid);
LogManager.d(TAG, "making scan filter with service mask: "+serviceUuidMaskString+" "+parcelUuidMask);
}
builder.setServiceUuid(parcelUuid, parcelUuidMask);
}
else {
builder.setServiceUuid(null);
builder.setManufacturerData((int) sfd.manufacturer, sfd.filter, sfd.mask);
}
ScanFilter scanFilter = builder.build();
if (LogManager.isVerboseLoggingEnabled()) {
LogManager.d(TAG, "Set up a scan filter: "+scanFilter);
}
scanFilters.add(scanFilter);
}
}
return scanFilters;
}
示例10: scan
import android.bluetooth.le.ScanFilter; //導入方法依賴的package包/類
@Override
public void scan(ReadableArray serviceUUIDs, final int scanSeconds, Callback callback) {
if(reactContext==null){
mCallback = callback;
}
ScanSettings settings = new ScanSettings.Builder().build();
List<ScanFilter> filters = new ArrayList<>();
if (serviceUUIDs != null && serviceUUIDs.size() > 0) {
for(int i = 0; i < serviceUUIDs.size(); i++){
ScanFilter.Builder builder = new ScanFilter.Builder();
builder.setServiceUuid(new ParcelUuid(UUIDHelper.uuidFromString(serviceUUIDs.getString(i))));
filters.add(builder.build());
Log.d(bleManager.LOG_TAG, "Filter service: " + serviceUUIDs.getString(i));
}
}
getBluetoothAdapter().getBluetoothLeScanner().startScan(filters, settings, mScanCallback);
if (scanSeconds > 0) {
Thread thread = new Thread() {
private int currentScanSession = scanSessionId.incrementAndGet();
@Override
public void run() {
try {
Thread.sleep(scanSeconds * 1000);
} catch (InterruptedException ignored) {
}
runOnUiThread(new Runnable() {
@Override
public void run() {
BluetoothAdapter btAdapter = getBluetoothAdapter();
// check current scan session was not stopped
if (scanSessionId.intValue() == currentScanSession) {
if(btAdapter.getState() == BluetoothAdapter.STATE_ON) {
btAdapter.getBluetoothLeScanner().stopScan(mScanCallback);
}
WritableMap map = Arguments.createMap();
bleManager.sendEvent("BleManagerStopScan", map);
}
if(mCallback!=null) {
mCallback.invoke();
mCallback=null;
}
}
});
}
};
thread.start();
}
if(reactContext!=null) {
callback.invoke();
}
}
示例11: convertCompatScanFilterToNative
import android.bluetooth.le.ScanFilter; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static ScanFilter convertCompatScanFilterToNative(com.taptrack.tcmptappy.blescannercompat.ScanFilter compatFilter) {
if(compatFilter == null)
return null;
ScanFilter.Builder nativeBuilder = new ScanFilter.Builder();
if(compatFilter.getDeviceAddress() != null)
nativeBuilder = nativeBuilder.setDeviceAddress(compatFilter.getDeviceAddress());
if(compatFilter.getDeviceName() != null)
nativeBuilder = nativeBuilder.setDeviceAddress(compatFilter.getDeviceName());
if(compatFilter.getManufacturerData() != null && compatFilter.getManufacturerId() != -1) {
if(compatFilter.getManufacturerDataMask() != null) {
nativeBuilder = nativeBuilder.setManufacturerData(compatFilter.getManufacturerId(),
compatFilter.getManufacturerData(),
compatFilter.getManufacturerDataMask());
}
else {
nativeBuilder = nativeBuilder.setManufacturerData(compatFilter.getManufacturerId(),
compatFilter.getManufacturerData());
}
}
if(compatFilter.getServiceDataUuid() != null && compatFilter.getServiceData() != null) {
if(compatFilter.getServiceDataMask() != null) {
nativeBuilder = nativeBuilder.setServiceData(compatFilter.getServiceDataUuid(),
compatFilter.getServiceData(),
compatFilter.getServiceDataMask());
}
else {
nativeBuilder = nativeBuilder.setServiceData(compatFilter.getServiceDataUuid(),
compatFilter.getServiceData());
}
}
if(compatFilter.getServiceUuid() != null) {
if(compatFilter.getServiceUuidMask() != null)
nativeBuilder = nativeBuilder.setServiceUuid(compatFilter.getServiceUuid(),compatFilter.getServiceUuidMask());
else
nativeBuilder = nativeBuilder.setServiceUuid(compatFilter.getServiceUuid());
}
return nativeBuilder.build();
}
示例12: getScanFilter
import android.bluetooth.le.ScanFilter; //導入方法依賴的package包/類
/**
* Return a {@link ScanFilter} matching the given {@link BeaconInterface}.
*
* @param beacon to create {@link ScanFilter} for
* @return {@link ScanFilter} that matches {@code beacon}
*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static ScanFilter getScanFilter(@NonNull final BeaconInterface beacon)
{
final ScanFilter.Builder builder = new ScanFilter.Builder();
// the manufacturer data byte is the filter!
final byte[] manufacturerData = new byte[]
{
0,0,
// uuid
0,0,0,0,
0,0,
0,0,
0,0,0,0,0,0,0,0,
// major
0,0,
// minor
0,0,
0
};
// the mask tells what bytes in the filter need to match, 1 if it has to match, 0 if not
final byte[] manufacturerDataMask = new byte[]
{
0,0,
// uuid
1,1,1,1,
1,1,
1,1,
1,1,1,1,1,1,1,1,
// major
1,1,
// minor
1,1,
0
};
// copy UUID (with no dashes) into data array
System.arraycopy(ConversionUtils.UuidToByteArray(beacon.getUUID()), 0, manufacturerData, 2, 16);
// copy major into data array
System.arraycopy(ConversionUtils.integerToByteArray(beacon.getMajor()), 0, manufacturerData, 18, 2);
// copy minor into data array
System.arraycopy(ConversionUtils.integerToByteArray(beacon.getMinor()), 0, manufacturerData, 20, 2);
builder.setManufacturerData(
MANUFACTURER_ID,
manufacturerData,
manufacturerDataMask);
return builder.build();
}
示例13: getScanFilter
import android.bluetooth.le.ScanFilter; //導入方法依賴的package包/類
private ScanFilter getScanFilter() {
ScanFilter.Builder builder = new ScanFilter.Builder();
builder.setServiceUuid(Beacon.EDDYSTONE_SPEC);
return builder.build();
}
示例14: createWildcardScanFilters
import android.bluetooth.le.ScanFilter; //導入方法依賴的package包/類
public List<ScanFilter> createWildcardScanFilters() {
List<ScanFilter> scanFilters = new ArrayList<ScanFilter>();
ScanFilter.Builder builder = new ScanFilter.Builder();
scanFilters.add(builder.build());
return scanFilters;
}