android.bluetooth.le.ScanResult Java Examples

The following examples show how to use android.bluetooth.le.ScanResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java    From Mi365Locker with GNU General Public License v3.0 9 votes vote down vote up
@Override
public void onScanResult(int callbackType, ScanResult result) {
    super.onScanResult(callbackType, result);

    BluetoothDevice newDevice = result.getDevice();

    int newRssi = result.getRssi();
    String device_name = newDevice.getName();
    String device_address = newDevice.getAddress();
    if(device_name == null)
    {
        return;
    }

    DeviceConnection dev = devices_connections.get(device_address);
    if(dev != null) {
        devicesAdapter.update(newDevice, newRssi, dev.getState());
    } else {
        devicesAdapter.update(newDevice, newRssi, RxBleConnection.RxBleConnectionState.DISCONNECTED);
    }

    String mDeviceAddress = newDevice.getAddress();
    add_device_to_attack(mDeviceAddress);
}
 
Example #2
Source File: RileyLinkBLEScanActivity.java    From AndroidAPS with GNU Affero General Public License v3.0 8 votes vote down vote up
private boolean addDevice(ScanResult result) {

            BluetoothDevice device = result.getDevice();

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

            if (serviceUuids == null || serviceUuids.size() == 0) {
                Log.v(TAG, "Device " + device.getAddress() + " has no serviceUuids (Not RileyLink).");
            } else if (serviceUuids.size() > 1) {
                Log.v(TAG, "Device " + device.getAddress() + " has too many serviceUuids (Not RileyLink).");
            } else {

                String uuid = serviceUuids.get(0).getUuid().toString().toLowerCase();

                if (uuid.equals(GattAttributes.SERVICE_RADIO)) {
                    Log.i(TAG, "Found RileyLink with address: " + device.getAddress());
                    mLeDeviceListAdapter.addDevice(result);
                    return true;
                } else {
                    Log.v(TAG, "Device " + device.getAddress() + " has incorrect uuid (Not RileyLink).");
                }
            }

            return false;
        }
 
Example #3
Source File: PeripheralScannerTest.java    From bitgatt with Mozilla Public License 2.0 8 votes vote down vote up
@Test
public void testConnectionAlreadyInMapDisconnectedScanResult() {
    MockScanResultProvider provider = new MockScanResultProvider(10, -167, -40);
    peripheralScanner.addRssiFilter(-10);
    ScanResult result = provider.getAllResults().get(0);
    FitbitBluetoothDevice device = new FitbitBluetoothDevice(result.getDevice());
    GattConnection conn = new GattConnection(device, mockLooper);
    conn.setMockMode(true);
    conn.setState(GattState.DISCONNECTED);
    gatt.getConnectionMap().put(device, conn);
    NoOpGattCallback cb = new NoOpGattCallback() {

        @Override
        public void onBluetoothPeripheralDiscovered(@NonNull GattConnection connection) {
            Assert.assertEquals(conn, connection);
            gatt.unregisterGattEventListener(this);
        }

    };
    gatt.registerGattEventListener(cb);
    peripheralScanner.populateMockScanResultIndividualValue(ScanSettings.CALLBACK_TYPE_FIRST_MATCH, result);
}
 
Example #4
Source File: ScanResultAdapter.java    From android-BluetoothAdvertisements with Apache License 2.0 6 votes vote down vote up
@Override
public View getView(int position, View view, ViewGroup parent) {

    // Reuse an old view if we can, otherwise create a new one.
    if (view == null) {
        view = mInflater.inflate(R.layout.listitem_scanresult, null);
    }

    TextView deviceNameView = (TextView) view.findViewById(R.id.device_name);
    TextView deviceAddressView = (TextView) view.findViewById(R.id.device_address);
    TextView lastSeenView = (TextView) view.findViewById(R.id.last_seen);

    ScanResult scanResult = mArrayList.get(position);

    String name = scanResult.getDevice().getName();
    if (name == null) {
        name = mContext.getResources().getString(R.string.no_name);
    }
    deviceNameView.setText(name);
    deviceAddressView.setText(scanResult.getDevice().getAddress());
    lastSeenView.setText(getTimeSinceString(mContext, scanResult.getTimestampNanos()));

    return view;
}
 
Example #5
Source File: ScanResultAdapter.java    From connectivity-samples with Apache License 2.0 6 votes vote down vote up
@Override
public View getView(int position, View view, ViewGroup parent) {

    // Reuse an old view if we can, otherwise create a new one.
    if (view == null) {
        view = mInflater.inflate(R.layout.listitem_scanresult, null);
    }

    TextView deviceNameView = (TextView) view.findViewById(R.id.device_name);
    TextView deviceAddressView = (TextView) view.findViewById(R.id.device_address);
    TextView lastSeenView = (TextView) view.findViewById(R.id.last_seen);

    ScanResult scanResult = mArrayList.get(position);

    String name = scanResult.getDevice().getName();
    if (name == null) {
        name = mContext.getResources().getString(R.string.no_name);
    }
    deviceNameView.setText(name);
    deviceAddressView.setText(scanResult.getDevice().getAddress());
    lastSeenView.setText(getTimeSinceString(mContext, scanResult.getTimestampNanos()));

    return view;
}
 
Example #6
Source File: DiscoverFragment.java    From bluetooth with Apache License 2.0 6 votes vote down vote up
@Override
public void onScanResult(int callbackType, ScanResult result) {
    super.onScanResult(callbackType, result);

    if (result == null || result.getDevice() == null) {
        logthis("The data result is empty or no data");
    } else {
        //should have useful info.
        //name
        StringBuilder builder = new StringBuilder("Name: ").append(result.getDevice().getName());
        //address
        builder.append("\n").append("address: ").append(result.getDevice().getAddress());
        //data
        builder.append("\n").append("data: ").append(new String(result.getScanRecord().getServiceData(result.getScanRecord().getServiceUuids().get(0)), Charset.forName("UTF-8")));
        logthis(builder.toString());
    }

}
 
Example #7
Source File: BluetoothCentralTest.java    From blessed-android with MIT License 6 votes vote down vote up
@Test
public void scanForPeripheralsTest()  throws Exception {
    application.grantPermissions(Manifest.permission.ACCESS_COARSE_LOCATION);
    central.scanForPeripherals();
    verify(scanner).startScan(anyList(), any(ScanSettings.class), any(ScanCallback.class));

    // Grab the scan callback that is used
    Field field = BluetoothCentral.class.getDeclaredField("scanByServiceUUIDCallback");
    field.setAccessible(true);
    ScanCallback scanCallback = (ScanCallback) field.get(central);

    // Fake scan result
    ScanResult scanResult = mock(ScanResult.class);
    BluetoothDevice device = mock(BluetoothDevice.class);
    when(device.getAddress()).thenReturn("00:00:00:00");
    when(scanResult.getDevice()).thenReturn(device);
    scanCallback.onScanResult(CALLBACK_TYPE_ALL_MATCHES, scanResult);

    // See if we get it back
    ArgumentCaptor<BluetoothPeripheral> bluetoothPeripheralCaptor = ArgumentCaptor.forClass(BluetoothPeripheral.class);
    ArgumentCaptor<ScanResult> scanResultCaptor = ArgumentCaptor.forClass(ScanResult.class);
    verify(callback).onDiscoveredPeripheral(bluetoothPeripheralCaptor.capture(), scanResultCaptor.capture());

    assertEquals(scanResultCaptor.getValue(), scanResult);
    assertEquals(bluetoothPeripheralCaptor.getValue().getAddress(), "00:00:00:00");
}
 
Example #8
Source File: BluetoothLeDeviceFilter.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/** @hide */
@Override
@Nullable
public String getDeviceDisplayName(ScanResult sr) {
    if (mRenameBytesFrom < 0 && mRenameNameFrom < 0) {
        return getDeviceDisplayNameInternal(sr.getDevice());
    }
    final StringBuilder sb = new StringBuilder(TextUtils.emptyIfNull(mRenamePrefix));
    if (mRenameBytesFrom >= 0) {
        final byte[] bytes = sr.getScanRecord().getBytes();
        int startInclusive = mRenameBytesFrom;
        int endInclusive = mRenameBytesFrom + mRenameBytesLength -1;
        int initial = mRenameBytesReverseOrder ? endInclusive : startInclusive;
        int step = mRenameBytesReverseOrder ? -1 : 1;
        for (int i = initial; startInclusive <= i && i <= endInclusive; i += step) {
            sb.append(Byte.toHexString(bytes[i], true));
        }
    } else {
        sb.append(
                getDeviceDisplayNameInternal(sr.getDevice())
                        .substring(mRenameNameFrom, mRenameNameFrom + mRenameNameLength));
    }
    return sb.append(TextUtils.emptyIfNull(mRenameSuffix)).toString();
}
 
Example #9
Source File: RileyLinkBLEScanActivity.java    From AndroidAPS with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void onBatchScanResults(final List<ScanResult> results) {

    runOnUiThread(() -> {

        boolean added = false;

        for (ScanResult result : results) {
            if (addDevice(result))
                added = true;
        }

        if (added)
            mLeDeviceListAdapter.notifyDataSetChanged();
    });
}
 
Example #10
Source File: MockScanResultProvider.java    From bitgatt with Mozilla Public License 2.0 6 votes vote down vote up
MockScanResultProvider(int numberOfMockResults, int minRssi, int maxRssi){
    rnd = new Random(System.currentTimeMillis());
    scanResults = new ArrayList<>(numberOfMockResults);
    serviceDataMap = new HashMap<>();
    byte[] randomData = new byte[16];
    rnd.nextBytes(randomData);
    serviceDataMap.put(new ParcelUuid(UUID.fromString("adabfb00-6e7d-4601-bda2-bffaa68956ba")), randomData);
    for(int i=0; i < numberOfMockResults; i++) {
        ScanResult result = Mockito.mock(ScanResult.class);
        BluetoothDevice device = Mockito.mock(BluetoothDevice.class);
        ScanRecord record = Mockito.mock(ScanRecord.class);
        Mockito.when(device.getAddress()).thenReturn(randomMACAddress());
        Mockito.when(device.getName()).thenReturn("foobar-" + String.valueOf(i));
        Mockito.when(result.getDevice()).thenReturn(device);
        Mockito.when(result.getRssi()).thenReturn(-1 * (rnd.nextInt(Math.abs(minRssi) + 1 - Math.abs(maxRssi)) + Math.abs(maxRssi)));
        Assert.assertTrue("Rssi is less than zero", result.getRssi() < 0);
        Mockito.when(record.getDeviceName()).thenReturn("foobar-" + String.valueOf(i));
        Mockito.when(record.getServiceData()).thenReturn(serviceDataMap);
        scanResults.add(result);
    }
}
 
Example #11
Source File: MockLollipopScanner.java    From bitgatt with Mozilla Public License 2.0 6 votes vote down vote up
public void onFoundOrLost(final boolean onFound, final ScanResult scanResult) {
    if (VDBG) {
        Log.d(TAG, "onFoundOrLost() - onFound = " + onFound + " " + scanResult.toString());
    }

    // Check null in case the scan has been stopped
    synchronized (this) {
        if (mScannerId <= 0) {
            return;
        }
    }
    Handler handler = mHandler;
    handler.post(new Runnable() {
        @Override
        public void run() {
            if (onFound) {
                mScanCallback.onScanResult(ScanSettings.CALLBACK_TYPE_FIRST_MATCH,
                    scanResult);
            } else {
                mScanCallback.onScanResult(ScanSettings.CALLBACK_TYPE_MATCH_LOST,
                    scanResult);
            }
        }
    });
}
 
Example #12
Source File: MockLollipopScanner.java    From bitgatt with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Callback reporting an LE scan result.
 */

public void onScanResult(final ScanResult scanResult) {
    if (VDBG) Log.d(TAG, "onScanResult() - " + scanResult.toString());

    // Check null in case the scan has been stopped
    synchronized (this) {
        if (mScannerId <= 0) return;
    }
    Handler handler = mHandler;
    handler.post(new Runnable() {
        @Override
        public void run() {
            mScanCallback.onScanResult(ScanSettings.CALLBACK_TYPE_ALL_MATCHES, scanResult);
        }
    });
}
 
Example #13
Source File: BleScanner.java    From EasyBle with Apache License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private boolean hasResultByFilterUuids(ScanResult result) {
    if (mServiceUuids == null || mServiceUuids.length <= 0) {//no filtered uuids
        return true;
    }
    ScanRecord scanRecord = result.getScanRecord();
    if (scanRecord == null) {
        return false;
    }
    List<ParcelUuid> serviceUuidList = new ArrayList<>();
    for (UUID uuid : mServiceUuids) {
        serviceUuidList.add(new ParcelUuid(uuid));
    }
    List<ParcelUuid> scanServiceUuids = result.getScanRecord().getServiceUuids();
    return scanServiceUuids != null && scanServiceUuids.containsAll(serviceUuidList);
}
 
Example #14
Source File: Wrappers.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onBatchScanResults(List<ScanResult> results) {
    ArrayList<ScanResultWrapper> resultsWrapped =
            new ArrayList<ScanResultWrapper>(results.size());
    for (ScanResult result : results) {
        resultsWrapped.add(new ScanResultWrapper(result));
    }
    mWrapperCallback.onBatchScanResult(resultsWrapped);
}
 
Example #15
Source File: BikeActivity.java    From android with MIT License 5 votes vote down vote up
@Override
public void onScanResult(int callbackType, ScanResult result) {
    super.onScanResult(callbackType, result);

    BluetoothDevice device = result.getDevice();
    String format = "Name:%s, Mac:%s, Type:%s";
    String msg = String.format(format, result.getDevice(), device.getAddress(), device.getType());
    print(msg);
}
 
Example #16
Source File: ScanResultAdapter.java    From android-BluetoothAdvertisements with Apache License 2.0 5 votes vote down vote up
/**
 * Add a ScanResult item to the adapter if a result from that device isn't already present.
 * Otherwise updates the existing position with the new ScanResult.
 */
public void add(ScanResult scanResult) {

    int existingPosition = getPosition(scanResult.getDevice().getAddress());

    if (existingPosition >= 0) {
        // Device is already in list, update its record.
        mArrayList.set(existingPosition, scanResult);
    } else {
        // Add new Device's ScanResult to list.
        mArrayList.add(scanResult);
    }
}
 
Example #17
Source File: BluetoothScannerImplLollipop.java    From Android-BLE with Apache License 2.0 5 votes vote down vote up
@Override
public void onScanResult(int callbackType, ScanResult result) {
    Log.e(TAG, "onScanResult: "+result.getScanRecord().getDeviceName());
    BluetoothDevice device = result.getDevice();
    byte[] scanRecord = result.getScanRecord().getBytes();
    if (scanWrapperCallback != null){
        scanWrapperCallback.onLeScan(device, result.getRssi(), scanRecord);
    }
    if (Ble.options().isParseScanData){
        ScanRecord parseRecord = ScanRecord.parseFromBytes(scanRecord);
        if (parseRecord != null && scanWrapperCallback != null) {
            scanWrapperCallback.onParsedData(device, parseRecord);
        }
    }
}
 
Example #18
Source File: MultipleBleService.java    From BleLib with Apache License 2.0 5 votes vote down vote up
@Override
public void onScanResult(int callbackType, ScanResult result) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (mScanLeDeviceList.contains(result.getDevice())) return;
        mScanLeDeviceList.add(result.getDevice());
        if (mOnLeScanListener != null) {
            mOnLeScanListener.onLeScan(result.getDevice(), result.getRssi(), result.getScanRecord().getBytes());
        }
        broadcastUpdate(ACTION_BLUETOOTH_DEVICE, result.getDevice());
        Log.i(TAG, "onScanResult: name: " + result.getDevice().getName() +
                ", address: " + result.getDevice().getAddress() +
                ", rssi: " + result.getRssi() + ", scanRecord: " + result.getScanRecord());
    }
}
 
Example #19
Source File: BluetoothLeScannerSnippet.java    From mobly-bundled-snippets with Apache License 2.0 5 votes vote down vote up
public void onBatchScanResults(List<ScanResult> results) {
    Log.i("Got Bluetooth LE batch scan results.");
    SnippetEvent event = new SnippetEvent(mCallbackId, "onBatchScanResult");
    ArrayList<Bundle> resultList = new ArrayList<>(results.size());
    for (ScanResult result : results) {
        resultList.add(mJsonSerializer.serializeBleScanResult(result));
    }
    event.getData().putParcelableArrayList("results", resultList);
    mEventCache.postEvent(event);
}
 
Example #20
Source File: RileyLinkBLEScanActivity.java    From AndroidAPS with GNU Affero General Public License v3.0 5 votes vote down vote up
public void addDevice(ScanResult result) {

            if (!mLeDevices.contains(result.getDevice())) {
                mLeDevices.add(result.getDevice());
            }
            rileyLinkDevices.put(result.getDevice(), result.getRssi());
            notifyDataSetChanged();
        }
 
Example #21
Source File: BleManager.java    From FastBle with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #22
Source File: BluetoothUtilImpl.java    From android-ponewheel with MIT License 5 votes vote down vote up
@Override
public void onScanResult(int callbackType, ScanResult result) {
    String deviceName = result.getDevice().getName();
    String deviceAddress = result.getDevice().getAddress();

    Timber.i( "ScanCallback.onScanResult: " + mScanResults.entrySet());
    if (!mScanResults.containsKey(deviceAddress)) {
        Timber.i( "ScanCallback.deviceName:" + deviceName);
        mScanResults.put(deviceAddress, deviceName);

        if (deviceName == null) {
            Timber.i("Found " + deviceAddress);
        } else {
            Timber.i("Found " + deviceAddress + " (" + deviceName + ")");
        }

        if (deviceName != null && (deviceName.startsWith("ow") || deviceName.startsWith("Onewheel"))) {
            mRetryCount = 0;
            Timber.i("Looks like we found our OW device (" + deviceName + ") discovering services!");
            connectToDevice(result.getDevice());
        } else {
            Timber.d("onScanResult: found another device:" + deviceName + "-" + deviceAddress);
        }

    } else {
        Timber.d("onScanResult: mScanResults already had our key, still connecting to OW services or something is up with the BT stack.");
      //  Timber.d("onScanResult: mScanResults already had our key," + "deviceName=" + deviceName + ",deviceAddress=" + deviceAddress);
        // still connect
        //connectToDevice(result.getDevice());
    }


}
 
Example #23
Source File: DeviceDiscovererV21.java    From science-journal with Apache License 2.0 5 votes vote down vote up
private void manageScanResult(ScanResult result) {
  List<String> serviceUuids = new ArrayList<>();
  ScanRecord record = result.getScanRecord();
  if (record != null) {
    List<ParcelUuid> parcelUuids = record.getServiceUuids();
    if (parcelUuids != null) {
      for (ParcelUuid uuid : parcelUuids) {
        serviceUuids.add(uuid.toString());
      }
    }
  }
  addOrUpdateDevice(new NativeDevice(result.getDevice(), serviceUuids), result.getRssi());
}
 
Example #24
Source File: BluetoothLeScannerSnippet.java    From mobly-bundled-snippets with Apache License 2.0 5 votes vote down vote up
public void onScanResult(int callbackType, ScanResult result) {
    Log.i("Got Bluetooth LE scan result.");
    SnippetEvent event = new SnippetEvent(mCallbackId, "onScanResult");
    String callbackTypeString =
            MbsEnums.BLE_SCAN_RESULT_CALLBACK_TYPE.getString(callbackType);
    event.getData().putString("CallbackType", callbackTypeString);
    event.getData().putBundle("result", mJsonSerializer.serializeBleScanResult(result));
    mEventCache.postEvent(event);
}
 
Example #25
Source File: ESenseScanner.java    From flutter-plugins with MIT License 5 votes vote down vote up
@Override
public void onScanResult(int callbackType, ScanResult result) {
    super.onScanResult(callbackType, result);
    BluetoothDevice _device = result.getDevice();
    if (_device != null && _device.getName() != null && _device.getName().matches(mDeviceName)) {
        stopScan();
        mDevice = _device;

        Log.i(TAG,"mac address : " + mDevice.getAddress() + ", name : " + mDevice.getName());
        mDeviceFoundLatch.countDown();
    }
}
 
Example #26
Source File: ScannerFragment.java    From android-BluetoothAdvertisements with Apache License 2.0 5 votes vote down vote up
@Override
public void onBatchScanResults(List<ScanResult> results) {
    super.onBatchScanResults(results);

    for (ScanResult result : results) {
        mAdapter.add(result);
    }
    mAdapter.notifyDataSetChanged();
}
 
Example #27
Source File: Device.java    From easyble-x with Apache License 2.0 5 votes vote down vote up
public void readFromParcel(Parcel in) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        this.scanResult = in.readParcelable(ScanResult.class.getClassLoader());
    }
    int scanRecordLen = in.readInt();
    if (scanRecordLen > 0) {
        this.scanRecord = new byte[scanRecordLen];
        in.readByteArray(this.scanRecord);
    }
    String inName = in.readString();
    this.name = inName == null ? "" : inName;
    this.address = Objects.requireNonNull(in.readString());
    this.rssi = in.readInt();
    this.connectionState = ConnectionState.valueOf(in.readString());
}
 
Example #28
Source File: BLEService.java    From android_wear_for_ios with MIT License 5 votes vote down vote up
@Override
        public void onScanResult(int callbackType, android.bluetooth.le.ScanResult result) {
            Log.d(TAG_LOG, "scan result" + result.toString());

            BluetoothDevice device = result.getDevice();

            if (!is_connect) {
                Log.d(TAG_LOG, "is connect");
                if (device != null) {
                    Log.d(TAG_LOG, "device ");
                    if (!is_reconnect && device.getName() != null) {
                        if(device.getName().equals("Blank")) {
//                        if(device.getName().equals("BLE Utility")) {
                            Log.d(TAG_LOG, "getname ");
                            iphone_uuid = device.getAddress().toString();
                            is_connect = true;
                            bluetooth_gatt = result.getDevice().connectGatt(getApplicationContext(), false, bluetooth_gattCallback);
                        }
                    } else if (is_reconnect && device.getAddress().toString().equals(iphone_uuid)) {
                        if(!is_time) {
                            Log.d(TAG_LOG, "-=-=-=-=-=-=-=-=-=- timer start:: -=-==-=-=-=-=-=-==--=-=-=-==-=-=-=-=-=-=-=-");
                            start_time = System.currentTimeMillis();
                            is_time = true;
                        }else if(System.currentTimeMillis() - start_time > 5000){
                            Log.d(TAG_LOG, "-=-=-=-=-=-=-=-=-=- reconnect:: -=-==-=-=-=-=-=-==--=-=-=-==-=-=-=-=-=-=-=-");
                            is_connect = true;
                            is_reconnect = false;
                            bluetooth_gatt = device.connectGatt(getApplicationContext(), true, bluetooth_gattCallback);
                        }
                    } else {
                        Log.d(TAG_LOG, "skip:: ");
                        skip_count++;
                    }
                }
            }
        }
 
Example #29
Source File: ScannerFragment.java    From android-BluetoothAdvertisements with Apache License 2.0 5 votes vote down vote up
@Override
public void onScanResult(int callbackType, ScanResult result) {
    super.onScanResult(callbackType, result);

    mAdapter.add(result);
    mAdapter.notifyDataSetChanged();
}
 
Example #30
Source File: ScannerFragment.java    From connectivity-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void onScanResult(int callbackType, ScanResult result) {
    super.onScanResult(callbackType, result);

    mAdapter.add(result);
    mAdapter.notifyDataSetChanged();
}