本文整理汇总了Java中android.bluetooth.le.ScanRecord.getDeviceName方法的典型用法代码示例。如果您正苦于以下问题:Java ScanRecord.getDeviceName方法的具体用法?Java ScanRecord.getDeviceName怎么用?Java ScanRecord.getDeviceName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.bluetooth.le.ScanRecord
的用法示例。
在下文中一共展示了ScanRecord.getDeviceName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ScanRecordCompat
import android.bluetooth.le.ScanRecord; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
ScanRecordCompat(ScanRecord record) {
mServiceUuids = record.getServiceUuids();
mManufacturerSpecificData = record.getManufacturerSpecificData();
mServiceData = record.getServiceData();
mDeviceName = record.getDeviceName();
mAdvertiseFlags = record.getAdvertiseFlags();
mTxPowerLevel = record.getTxPowerLevel();
mBytes = record.getBytes();
}
示例2: initScanData
import android.bluetooth.le.ScanRecord; //导入方法依赖的package包/类
private void initScanData() {
scanCallback = new ScanCallback() {
@Override
public void onScanResult(int callbackType, ScanResult result) {
super.onScanResult(callbackType, result);
Log.i(TAG, "onScanResult" + result);
String address = result.getDevice().getAddress();
String name;
ScanRecord scanRecord = result.getScanRecord();
name = scanRecord == null ? "unknown" : scanRecord.getDeviceName();
scanResultListener.onResultReceived(name, address);
}
@Override
public void onBatchScanResults(List<ScanResult> results) {
super.onBatchScanResults(results);
Log.e(TAG, "onBatchScanResults");
}
@Override
public void onScanFailed(int errorCode) {
super.onScanFailed(errorCode);
Log.e(TAG, "onScanFailed");
scanResultListener.onScanFailed(errorCode);
}
};
filters = new ArrayList<>();
filters.add(new ScanFilter.Builder().setServiceUuid(ParcelUuid.fromString(BLEProfile.UUID_SERVICE)).build());
scanSettings = new ScanSettings.Builder().setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build();
}
示例3: TemperatureBeacon
import android.bluetooth.le.ScanRecord; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public TemperatureBeacon(ScanRecord record, String deviceAddress, int rssi) {
mSignal = rssi;
mAddress = deviceAddress;
mName = record.getDeviceName();
byte[] data = record.getServiceData(THERM_SERVICE);
if (data != null) {
mCurrentTemp = parseTemp(data);
} else {
mCurrentTemp = 0f;
}
}
示例4: initScanData
import android.bluetooth.le.ScanRecord; //导入方法依赖的package包/类
private void initScanData() {
scanCallback = new ScanCallback() {
@Override
public void onScanResult(int callbackType, ScanResult result) {
super.onScanResult(callbackType, result);
Log.d(TAG, "["+
Thread.currentThread().getStackTrace()[2].getFileName() + "_" +
Thread.currentThread().getStackTrace()[2].getLineNumber() + "_" +
Thread.currentThread().getStackTrace()[2].getMethodName() + "]");
Log.i(TAG, "result" + result);
String address = result.getDevice().getAddress();
String name;
ScanRecord scanRecord = result.getScanRecord();
int mRssi = result == null ? -127: result.getRssi();
Log.i(TAG, "Rssi: " +mRssi);
name = scanRecord == null ? "unknown" : scanRecord.getDeviceName();
//TODO stop scan
// if (name != null)
// {
// Log.d(TAG, "["+
// Thread.currentThread().getStackTrace()[2].getFileName() + "_" +
// Thread.currentThread().getStackTrace()[2].getLineNumber() + "_" +
// Thread.currentThread().getStackTrace()[2].getMethodName() + "]" + "========StopScan");
// stopScan();
// }
scanResultListener.onResultReceived(name, address, mRssi);
}
@Override
public void onBatchScanResults(List<ScanResult> results) {
super.onBatchScanResults(results);
Log.d(TAG, "["+
Thread.currentThread().getStackTrace()[2].getFileName() + "_" +
Thread.currentThread().getStackTrace()[2].getLineNumber() + "_" +
Thread.currentThread().getStackTrace()[2].getMethodName() + "]");
Log.e(TAG, "onBatchScanResults");
}
@Override
public void onScanFailed(int errorCode) {
super.onScanFailed(errorCode);
Log.d(TAG, "["+
Thread.currentThread().getStackTrace()[2].getFileName() + "_" +
Thread.currentThread().getStackTrace()[2].getLineNumber() + "_" +
Thread.currentThread().getStackTrace()[2].getMethodName() + "]");
Log.e(TAG, "onScanFailed");
scanResultListener.onScanFailed(errorCode);
}
};
filters = new ArrayList<>();
filters.add(new ScanFilter.Builder().setServiceUuid(ParcelUuid.fromString(BLEProfile.UUID_SERVICE)).build());
scanSettings = new ScanSettings.Builder().setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build();
}