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


Java ScanRecord.getDeviceName方法代码示例

本文整理汇总了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();
}
 
开发者ID:Twelvelines,项目名称:AndroidMuseumBleManager,代码行数:11,代码来源:ScanRecordCompat.java

示例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();
}
 
开发者ID:czvn,项目名称:Android-BLE-Library,代码行数:31,代码来源:BLEScanner.java

示例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;
    }
}
 
开发者ID:ruipoliveira,项目名称:livingCity-Android,代码行数:15,代码来源:TemperatureBeacon.java

示例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();
    }
 
开发者ID:AnXi-TieGuanYin-Tea,项目名称:AndroidBluttoothMasterAndSlave,代码行数:55,代码来源:BLEScanner.java


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