本文整理汇总了Java中no.nordicsemi.android.support.v18.scanner.ScanFilter类的典型用法代码示例。如果您正苦于以下问题:Java ScanFilter类的具体用法?Java ScanFilter怎么用?Java ScanFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScanFilter类属于no.nordicsemi.android.support.v18.scanner包,在下文中一共展示了ScanFilter类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: startLeScan
import no.nordicsemi.android.support.v18.scanner.ScanFilter; //导入依赖的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
示例2: startScan
import no.nordicsemi.android.support.v18.scanner.ScanFilter; //导入依赖的package包/类
/**
* Start scanning for Bluetooth devices.
*/
public void startScan() {
if (mScannerLiveData.isScanning()) {
return;
}
// Scanning settings
final ScanSettings settings = new ScanSettings.Builder()
.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
// Refresh the devices list every second
.setReportDelay(0)
// Hardware filtering has some issues on selected devices
.setUseHardwareFilteringIfSupported(false)
// Samsung S6 and S6 Edge report equal value of RSSI for all devices. In this app we ignore the RSSI.
/*.setUseHardwareBatchingIfSupported(false)*/
.build();
// Let's use the filter to scan only for Blinky devices
final ParcelUuid uuid = new ParcelUuid(BlinkyManager.LBS_UUID_SERVICE);
final List<ScanFilter> filters = new ArrayList<>();
filters.add(new ScanFilter.Builder().setServiceUuid(uuid).build());
final BluetoothLeScannerCompat scanner = BluetoothLeScannerCompat.getScanner();
scanner.startScan(filters, settings, scanCallback);
mScannerLiveData.scanningStarted();
}
开发者ID:NordicSemiconductor,项目名称:Android-nRF-Blinky,代码行数:29,代码来源:ScannerViewModel.java
示例3: prepareForScan
import no.nordicsemi.android.support.v18.scanner.ScanFilter; //导入依赖的package包/类
private void prepareForScan(){
if(isBleSupported()) {
final ParcelUuid uuid = NODE_CONFIGURATION_SERVICE;
mScanFilterList = new ArrayList<>();
mScanFilterList.add(new ScanFilter.Builder().setServiceUuid(uuid).build());
mScanner = BluetoothLeScannerCompat.getScanner();
if (checkIfVersionIsMarshmallowOrAbove()) {
startLocationModeChangeReceiver();
connectToGoogleApiClient();
} else {
if (!isBleEnabled()) {
final Intent bluetoothEnable = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(bluetoothEnable, REQUEST_ENABLE_BT);
} else {
startLeScan();
}
}
} else {
showError(getString(R.string.ble_not_supported), false);
}
}
开发者ID:NordicSemiconductor,项目名称:Android-nRF-BLE-Joiner,代码行数:23,代码来源:MainActivity.java
示例4: startScan
import no.nordicsemi.android.support.v18.scanner.ScanFilter; //导入依赖的package包/类
/**
* Scan for 5 seconds and then stop scanning when a BluetoothLE device is found then mLEScanCallback is activated This will perform regular scan for custom BLE Service UUID and then filter out.
* using class ScannerServiceParser
*/
private void startScan() {
// Since Android 6.0 we need to obtain either Manifest.permission.ACCESS_COARSE_LOCATION or Manifest.permission.ACCESS_FINE_LOCATION to be able to scan for
// Bluetooth LE devices. This is related to beacons as proximity devices.
// On API older than Marshmallow the following code does nothing.
if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// When user pressed Deny and still wants to use this functionality, show the rationale
if (ActivityCompat.shouldShowRequestPermissionRationale(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) && mPermissionRationale.getVisibility() == View.GONE) {
mPermissionRationale.setVisibility(View.VISIBLE);
return;
}
requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, REQUEST_PERMISSION_REQ_CODE);
return;
}
// Hide the rationale message, we don't need it anymore.
if (mPermissionRationale != null)
mPermissionRationale.setVisibility(View.GONE);
mAdapter.clearDevices();
mScanButton.setText(R.string.scanner_action_cancel);
final BluetoothLeScannerCompat scanner = BluetoothLeScannerCompat.getScanner();
final ScanSettings settings = new ScanSettings.Builder()
.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).setReportDelay(1000).setUseHardwareBatchingIfSupported(false).build();
final List<ScanFilter> filters = new ArrayList<>();
filters.add(new ScanFilter.Builder().setServiceUuid(mUuid).build());
scanner.startScan(filters, settings, scanCallback);
mIsScanning = true;
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
if (mIsScanning) {
stopScan();
}
}
}, SCAN_DURATION);
}
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:44,代码来源:ScannerFragment.java
示例5: startScan
import no.nordicsemi.android.support.v18.scanner.ScanFilter; //导入依赖的package包/类
/**
* Scan for 5 seconds and then stop scanning when a BluetoothLE device is found then mLEScanCallback is activated This will perform regular scan for custom BLE Service UUID and then filter out
* using class ScannerServiceParser
*/
private void startScan() {
// Since Android 6.0 we need to obtain either Manifest.permission.ACCESS_COARSE_LOCATION or Manifest.permission.ACCESS_FINE_LOCATION to be able to scan for
// Bluetooth LE devices. This is related to beacons as proximity devices.
// On API older than Marshmallow the following code does nothing.
if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// When user pressed Deny and still wants to use this functionality, show the rationale
if (ActivityCompat.shouldShowRequestPermissionRationale(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) && mPermissionRationale.getVisibility() == View.GONE) {
mPermissionRationale.setVisibility(View.VISIBLE);
return;
}
requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, REQUEST_PERMISSION_REQ_CODE);
return;
}
// Hide the rationale message, we don't need it anymore.
if (mPermissionRationale != null)
mPermissionRationale.setVisibility(View.GONE);
mAdapter.clearDevices();
mScanButton.setText(R.string.scanner_action_cancel);
final BluetoothLeScannerCompat scanner = BluetoothLeScannerCompat.getScanner();
final ScanSettings settings = new ScanSettings.Builder()
.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).setReportDelay(1000).setUseHardwareBatchingIfSupported(false).setUseHardwareFilteringIfSupported(false).build();
final List<ScanFilter> filters = new ArrayList<>();
filters.add(new ScanFilter.Builder().setServiceUuid(mUuid).build());
scanner.startScan(filters, settings, scanCallback);
mIsScanning = true;
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
if (mIsScanning) {
stopScan();
}
}
}, SCAN_DURATION);
}
开发者ID:NordicSemiconductor,项目名称:Android-nRF-Beacon-for-Eddystone,代码行数:44,代码来源:ScannerFragment.java
示例6: startScan
import no.nordicsemi.android.support.v18.scanner.ScanFilter; //导入依赖的package包/类
/**
* Scan for 5 seconds and then stop scanning when a BluetoothLE device is found then mLEScanCallback is activated This will perform regular scan for custom BLE Service UUID and then filter out.
* using class ScannerServiceParser
*/
private void startScan() {
// Since Android 6.0 we need to obtain either Manifest.permission.ACCESS_COARSE_LOCATION or Manifest.permission.ACCESS_FINE_LOCATION to be able to scan for
// Bluetooth LE devices. This is related to beacons as proximity devices.
// On API older than Marshmallow the following code does nothing.
if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// When user pressed Deny and still wants to use this functionality, show the rationale
if (ActivityCompat.shouldShowRequestPermissionRationale(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) && mPermissionRationale.getVisibility() == View.GONE) {
mPermissionRationale.setVisibility(View.VISIBLE);
return;
}
requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, REQUEST_PERMISSION_REQ_CODE);
return;
}
// Hide the rationale message, we don't need it anymore.
if (mPermissionRationale != null)
mPermissionRationale.setVisibility(View.GONE);
mAdapter.clearDevices();
mScanButton.setText(R.string.scanner_action_cancel);
final BluetoothLeScannerCompat scanner = BluetoothLeScannerCompat.getScanner();
final ScanSettings settings = new ScanSettings.Builder()
.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).setReportDelay(1000).setUseHardwareBatchingIfSupported(false).build();
final List<ScanFilter> filters = new ArrayList<>();
filters.add(new ScanFilter.Builder().setServiceUuid(mUuid).build());
scanner.startScan(filters, settings, scanCallback);
mIsScanning = true;
mHandler.postDelayed(() -> {
if (mIsScanning) {
stopScan();
}
}, SCAN_DURATION);
}
开发者ID:NordicSemiconductor,项目名称:Android-nRF-Toolbox,代码行数:41,代码来源:ScannerFragment.java
注:本文中的no.nordicsemi.android.support.v18.scanner.ScanFilter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论