本文整理汇总了Java中no.nordicsemi.android.support.v18.scanner.ScanSettings类的典型用法代码示例。如果您正苦于以下问题:Java ScanSettings类的具体用法?Java ScanSettings怎么用?Java ScanSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScanSettings类属于no.nordicsemi.android.support.v18.scanner包,在下文中一共展示了ScanSettings类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: startLeScan
import no.nordicsemi.android.support.v18.scanner.ScanSettings; //导入依赖的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: startLeScan
import no.nordicsemi.android.support.v18.scanner.ScanSettings; //导入依赖的package包/类
public void startLeScan() {
// Scanning is disabled when we are connecting or connected.
if (mConnectingPosition >= 0)
return;
if (mScanning) {
// Extend scanning for some time more
mHandler.removeCallbacks(mStopScanTask);
mHandler.postDelayed(mStopScanTask, SCAN_DURATION);
return;
}
final BluetoothLeScannerCompat scanner = BluetoothLeScannerCompat.getScanner();
final ScanSettings settings = new ScanSettings.Builder().setReportDelay(1000).setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build();
scanner.startScan(null, settings, mScanCallback);
// Setup timer that will stop scanning
mHandler.postDelayed(mStopScanTask, SCAN_DURATION);
mScanning = true;
notifyItemChanged(mDevices.size());
}
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:22,代码来源:DevicesAdapter.java
示例3: onScanStarted
import no.nordicsemi.android.support.v18.scanner.ScanSettings; //导入依赖的package包/类
private void onScanStarted() {
Log.i(TAG,"onScanStarted() mScanning " + mScanning);
if (mScanning)
return;
mScanning = true;
// Stops scanning after a pre-defined scan period.
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
onScanFinished();
}
}, mScanPeriod);
//mBluetoothAdapter.startLeScan(mLeScanCallback);
ScanSettings settings = new ScanSettings.Builder()
.setCallbackType(ScanSettings.CALLBACK_TYPE_ALL_MATCHES)
.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
.setReportDelay(0).build();
mScanner.startScan(null, settings, mScanCallback);
}
开发者ID:NordicID,项目名称:nur_sample_android,代码行数:24,代码来源:BleScanner.java
示例4: startScan
import no.nordicsemi.android.support.v18.scanner.ScanSettings; //导入依赖的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
示例5: startLeScan
import no.nordicsemi.android.support.v18.scanner.ScanSettings; //导入依赖的package包/类
private void startLeScan(){
final ScanSettings settings = new ScanSettings.Builder()
.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
// Refresh the devices list every second
.setReportDelay(1000)
// 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();
mHandler.postDelayed(mStopScanningTask, SCAN_PERIOD);
mScanning = true;
mBleDeviceListAdapter.clear();
mScanner.startScan(mScanFilterList, settings, scanCallback);
invalidateOptionsMenu();
}
开发者ID:NordicSemiconductor,项目名称:Android-nRF-BLE-Joiner,代码行数:17,代码来源:MainActivity.java
示例6: startScan
import no.nordicsemi.android.support.v18.scanner.ScanSettings; //导入依赖的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
示例7: startScan
import no.nordicsemi.android.support.v18.scanner.ScanSettings; //导入依赖的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
示例8: startScan
import no.nordicsemi.android.support.v18.scanner.ScanSettings; //导入依赖的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.ScanSettings类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论