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


Java ScanResult.getDevice方法代码示例

本文整理汇总了Java中android.bluetooth.le.ScanResult.getDevice方法的典型用法代码示例。如果您正苦于以下问题:Java ScanResult.getDevice方法的具体用法?Java ScanResult.getDevice怎么用?Java ScanResult.getDevice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.bluetooth.le.ScanResult的用法示例。


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

示例1: onBatchScanResults

import android.bluetooth.le.ScanResult; //导入方法依赖的package包/类
public void onBatchScanResults(List<ScanResult> results) {
    CallsCounter.logCounter(context, "BluetoothLEScanCallback21.onBatchScanResults", "BluetoothLEScanCallback21.onBatchScanResults");

    boolean scanStarted = (BluetoothScanJob.getWaitForLEResults(context));

    if (scanStarted) {
        for (ScanResult result : results) {
            //PPApplication.logE("BluetoothLEScanCallback21", "onBatchScanResults - result=" + result.toString());

            BluetoothDevice device = result.getDevice();
            String btName = device.getName();
            PPApplication.logE("BluetoothLEScanCallback21", "onBatchScanResults - deviceName=" + btName);

            BluetoothDeviceData deviceData = new BluetoothDeviceData(btName, device.getAddress(),
                    BluetoothScanJob.getBluetoothType(device), false, 0);

            BluetoothScanJob.addLEScanResult(deviceData);
        }
    }
}
 
开发者ID:henrichg,项目名称:PhoneProfilesPlus,代码行数:21,代码来源:BluetoothLEScanCallback21.java

示例2: onScanResult

import android.bluetooth.le.ScanResult; //导入方法依赖的package包/类
@Override
public void onScanResult(int callbackType, ScanResult result) {
    super.onScanResult(callbackType, result);
    BluetoothDevice device = result.getDevice();
    if ( device != null )
    {
        String msg = device.getName() + "\n" +"[RSSI : " + result.getRssi() + "dBm]" + device.getAddress();
        NLog.d( "onLeScan " + msg );

        /**
         * setting pen client control for ble
         */
            if(!temp.contains( device.getAddress() ))
            {
                NLog.d( "ACTION_FOUND onLeScan : " +device.getName() + " address : "+ device.getAddress()+", COD:" + device.getBluetoothClass());
                temp.add( device.getAddress());
                mNewDevicesArrayAdapter.add(msg);
            }
    }
}
 
开发者ID:NeoSmartpen,项目名称:AndroidSDK2.0,代码行数:21,代码来源:DeviceListActivity.java

示例3: onScanResult

import android.bluetooth.le.ScanResult; //导入方法依赖的package包/类
@Override
public void onScanResult(int callbackType, ScanResult result) {
	super.onScanResult(callbackType, result);
	if (devices != null) {
		BluetoothDevice device = result.getDevice();				
		/*
		if ((device.getName() != null) && !devices.containsKey(device.getAddress())) {
			debug("New device detected " + device.getAddress() + " " + device.getName());
			if (device.getName().toUpperCase().contains("U2F")) {					
				devices.put(device.getAddress(), device);
			}
		}
		*/
		if (!devices.containsKey(device.getAddress())) {
			debug("New device detected " + device.getAddress() + "/" + (device.getName() != null ? device.getName() : ""));					
			devices.put(device.getAddress(), device);
		}				
	}
}
 
开发者ID:LedgerHQ,项目名称:u2f-ble-test,代码行数:20,代码来源:MainActivity.java

示例4: convertBleDevice

import android.bluetooth.le.ScanResult; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public BleDevice convertBleDevice(ScanResult scanResult) {
    if (scanResult == null) {
        throw new IllegalArgumentException("scanResult can not be Null!");
    }
    BluetoothDevice bluetoothDevice = scanResult.getDevice();
    int rssi = scanResult.getRssi();
    ScanRecord scanRecord = scanResult.getScanRecord();
    byte[] bytes = null;
    if (scanRecord != null)
        bytes = scanRecord.getBytes();
    long timestampNanos = scanResult.getTimestampNanos();
    return new BleDevice(bluetoothDevice, rssi, bytes, timestampNanos);
}
 
开发者ID:Jasonchenlijian,项目名称:FastBle,代码行数:15,代码来源:BleManager.java

示例5: onScanResult

import android.bluetooth.le.ScanResult; //导入方法依赖的package包/类
@Override
public void onScanResult(int callbackType, ScanResult result) {
    BluetoothDevice device = result.getDevice();
    Log.d(TAG, "scaning finished: "+device);
    if (device != null) {
        int toRemove = -1;
        for (int i = 0; i < beaconList.size(); i++) {
            if (device.getAddress().equals(beaconList.get(i).getMac())) {
                toRemove = i;
            }
        }

        if (toRemove != -1) {
            beaconList.remove(toRemove);

        }


    }
}
 
开发者ID:WillyShakes,项目名称:UdooWtf,代码行数:21,代码来源:MainActivity.java

示例6: ScanResultCompat

import android.bluetooth.le.ScanResult; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
ScanResultCompat(ScanResult result) {
    mDevice = result.getDevice();
    mScanRecord = new ScanRecordCompat(result.getScanRecord());
    mRssi = result.getRssi();
    mTimestampNanos = result.getTimestampNanos();
}
 
开发者ID:joerogers,项目名称:BluetoothCompat,代码行数:8,代码来源:ScanResultCompat.java

示例7: onScanResult

import android.bluetooth.le.ScanResult; //导入方法依赖的package包/类
@Override
public void onScanResult(int callbackType, ScanResult result)
{
    BluetoothDevice device = result.getDevice();
    String mac_address = device.getAddress();

    boolean foundOurDevice = false;
    for (int i = 0; i < NUM_WORKOUTS; i++)
    {
        if (Gym.get(i).getMac_address().equals(mac_address) && Gym.get(i).getRSSI() == errorValue)
        {
            Gym.get(i).setRSSI(result.getRssi());
            Log.i(DEBUG, "Found one of our devices: " + mac_address);
            foundOurDevice = true;
            break;
        }
    }

    if (!foundOurDevice)
        Log.i(DEBUG, "Found another Bluetooth device.");
}
 
开发者ID:bbrown1867,项目名称:Freeweight,代码行数:22,代码来源:BluetoothAndroid.java

示例8: onScanResult

import android.bluetooth.le.ScanResult; //导入方法依赖的package包/类
@Override
public void onScanResult(int callbackType, ScanResult result) {
    super.onScanResult(callbackType, result);

    BluetoothDevice device = result.getDevice();

    System.out.println("I see a bluetooth device: " + device.getAddress());

    List<ParcelUuid> uuids = result.getScanRecord().getServiceUuids();

    if(uuids != null) {
        for (ParcelUuid uuid :uuids) {
            System.out.println("Service UUID: " + uuid.getUuid());
        }
    }

    device.connectGatt(context, false, gattCallback);
}
 
开发者ID:tripzero,项目名称:SuperPanel,代码行数:19,代码来源:Ble.java

示例9: onScanResult

import android.bluetooth.le.ScanResult; //导入方法依赖的package包/类
@Override
public void onScanResult(int callbackType, ScanResult result) {
    super.onScanResult(callbackType, result);
    BluetoothDevice device = result.getDevice();
    String deviceAddress = device.getAddress();
    String deviceName = device.getName();

    String msg = "name=" + device.getName() + ", bondStatus="
            + device.getBondState() + ", address="
            + device.getAddress() + ", type" + device.getType();
    Log.d(TAG, msg);

    Pair<String, String> foundDevice = new Pair<>(deviceName, deviceAddress);
    if (!deviceList.contains(foundDevice)) {
        deviceList.add(foundDevice);
    }
}
 
开发者ID:cortinico,项目名称:myo-emg-visualizer,代码行数:18,代码来源:MyoListFragment.java

示例10: onScanResult

import android.bluetooth.le.ScanResult; //导入方法依赖的package包/类
public void onScanResult(int callbackType, ScanResult result) {
    CallsCounter.logCounter(context, "BluetoothLEScanCallback21.onScanResult", "BluetoothLEScanCallback21.onScanResult");

    boolean scanStarted = (BluetoothScanJob.getWaitForLEResults(context));

    if (scanStarted) {
        //PPApplication.logE("BluetoothLEScanCallback21", "onScanResult - callbackType=" + callbackType);
        //PPApplication.logE("BluetoothLEScanCallback21", "onScanResult - result=" + result.toString());

        BluetoothDevice device = result.getDevice();
        String btName = device.getName();
        PPApplication.logE("BluetoothLEScanCallback21", "onScanResult - deviceName=" + btName);

        BluetoothDeviceData deviceData = new BluetoothDeviceData(btName, device.getAddress(),
                BluetoothScanJob.getBluetoothType(device), false, 0);

        BluetoothScanJob.addLEScanResult(deviceData);
    }
}
 
开发者ID:henrichg,项目名称:PhoneProfilesPlus,代码行数:20,代码来源:BluetoothLEScanCallback21.java

示例11: createCallback

import android.bluetooth.le.ScanResult; //导入方法依赖的package包/类
private static android.bluetooth.le.ScanCallback createCallback(ScanCallback scanCallback) {
    return new android.bluetooth.le.ScanCallback() {
        @Override
        public void onScanResult(int callbackType, ScanResult result) {

            BluetoothDevice device = result.getDevice();
            int rssi = result.getRssi();
            byte[] scanRecord = (result.getScanRecord() != null ? result.getScanRecord().getBytes() : null);
            scanCallback.onDeviceFound(device, rssi, scanRecord);

            super.onScanResult(callbackType, result);
        }

        @Override
        public void onBatchScanResults(List<ScanResult> results) {
            super.onBatchScanResults(results);
        }

        @Override
        public void onScanFailed(int errorCode) {
            super.onScanFailed(errorCode);
        }
    };
}
 
开发者ID:devicehive,项目名称:android-ble,代码行数:25,代码来源:BleScannerL.java

示例12: onScanResult

import android.bluetooth.le.ScanResult; //导入方法依赖的package包/类
@Override
public void onScanResult(int callbackType, ScanResult result) {
    boolean isDuplicate = false;

    //filter out duplicate entries if requested
    if(!rnbleModule.allowDuplicates){                
        for(String s : scannedDeviceAddresses){
            BluetoothDevice device = result.getDevice();
            String address = device.getAddress();

            if(s.equals(address)) {
               isDuplicate = true;
               break;
            }
        }
    }

    if(!isDuplicate){  
        scannedDeviceAddresses.add(result.getDevice().getAddress());
        super.onScanResult(callbackType, result);
        processScanResult(result);
    }
}
 
开发者ID:jacobrosenthal,项目名称:react-native-ble,代码行数:24,代码来源:RNBLEModule.java

示例13: initCallbacks

import android.bluetooth.le.ScanResult; //导入方法依赖的package包/类
private ScanCallback initCallbacks() {
    return new ScanCallback() {
        @Override
        public void onScanResult(int callbackType, ScanResult result) {
            super.onScanResult(callbackType, result);

            if (result != null && result.getDevice() != null) {
                if (isAdded(result.getDevice())) {
                    // No add
                } else {
                    saveDevice(result.getDevice());
                }
            }

        }

        @Override
        public void onBatchScanResults(List<ScanResult> results) {
            super.onBatchScanResults(results);
        }

        @Override
        public void onScanFailed(int errorCode) {
            super.onScanFailed(errorCode);
        }
    };
}
 
开发者ID:jphacks,项目名称:KB_1711,代码行数:28,代码来源:MainActivity.java

示例14: onScanResult

import android.bluetooth.le.ScanResult; //导入方法依赖的package包/类
/**
 * Callback when a BLE advertisement has been found.
 *
 * @param callbackType Determines how this callback was triggered.
 * @param result       A Bluetooth LE scan result.
 */
@Override
public void onScanResult(int callbackType, final ScanResult result) {
    super.onScanResult(callbackType, result);

    // Get the ScanRecord and check if it is defined (is nullable)
    final ScanRecord scanRecord = result.getScanRecord();
    if (scanRecord != null) {
        // Check if the Service UUIDs are defined (is nullable) and contain the discovery
        // UUID
        final List<ParcelUuid> serviceUuids = scanRecord.getServiceUuids();
        if (serviceUuids != null && serviceUuids.contains(DISCOVERY_UUID)) {
            // We have found our device, so update the GUI, stop scanning and start
            // connecting
            final BluetoothDevice device = result.getDevice();

            // We'll make sure the GUI is updated on the UI thread
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    // At this point we have the device address and RSSI, so update those
                    deviceAddressTextView.setText(device.getAddress());
                    rssiTextView.setText(getString(R.string.rssi, result.getRssi()));
                }
            });

            stopDiscovery();

            bluetoothGatt = device.connectGatt(
                    MainActivity.this,
                    // False here, as we want to directly connect to the device
                    false,
                    bluetoothGattCallback
            );
        }
    }
}
 
开发者ID:SPINremote,项目名称:sdc-1-quickstart-android,代码行数:43,代码来源:MainActivity.java

示例15: ScanResultCompat

import android.bluetooth.le.ScanResult; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
ScanResultCompat(ScanResult result) {
    mDevice = new BluetoothLeDevice(result.getDevice(), result.getRssi(), result.getScanRecord().getBytes(), System.currentTimeMillis());//result.getTimestampNanos()
    mScanRecord = new ScanRecordCompat(result.getScanRecord());
    mRssi = result.getRssi();
    mTimestampNanos = System.currentTimeMillis();//result.getTimestampNanos();
}
 
开发者ID:Twelvelines,项目名称:AndroidMuseumBleManager,代码行数:8,代码来源:ScanResultCompat.java


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