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


Java BluetoothAdapter.LeScanCallback方法代码示例

本文整理汇总了Java中android.bluetooth.BluetoothAdapter.LeScanCallback方法的典型用法代码示例。如果您正苦于以下问题:Java BluetoothAdapter.LeScanCallback方法的具体用法?Java BluetoothAdapter.LeScanCallback怎么用?Java BluetoothAdapter.LeScanCallback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.bluetooth.BluetoothAdapter的用法示例。


在下文中一共展示了BluetoothAdapter.LeScanCallback方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.bluetooth.BluetoothAdapter; //导入方法依赖的package包/类
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // initialize the right scan callback for the current API level
    if (Build.VERSION.SDK_INT >= 21) {
        mScanCallback = new ScanCallback() {
            @Override
            public void onScanResult(int callbackType, ScanResult result) {
                super.onScanResult(callbackType, result);
                mRecyclerViewAdapter.addDevice(result.getDevice().getAddress());
            }
        };
    } else {
        mLeScanCallback = new BluetoothAdapter.LeScanCallback() {
            @Override
            public void onLeScan(BluetoothDevice bluetoothDevice, int i, byte[] bytes) {
                mRecyclerViewAdapter.addDevice(bluetoothDevice.getAddress());
            }
        };
    }

    // initialize bluetooth manager & adapter
    BluetoothManager manager = (BluetoothManager) getActivity().getSystemService(Context.BLUETOOTH_SERVICE);
    mBluetoothAdapter = manager.getAdapter();
}
 
开发者ID:martindisch,项目名称:SensorTag-Accelerometer,代码行数:27,代码来源:ScanFragment.java

示例2: stopScan

import android.bluetooth.BluetoothAdapter; //导入方法依赖的package包/类
/**
 * 停止扫描蓝牙设备
 *
 * @param callback
 */
public void stopScan(BluetoothAdapter.LeScanCallback callback) {
    bluetoothAdapter.stopLeScan(callback);
    if (connectionState == STATE_SCANNING) {
        connectionState = STATE_DISCONNECTED;
    }
}
 
开发者ID:qiu-yongheng,项目名称:Bluetooth_BLE,代码行数:12,代码来源:BleManager.java

示例3: stopScan

import android.bluetooth.BluetoothAdapter; //导入方法依赖的package包/类
/**
 * 停止搜索
 * @param callback
 */
public void stopScan(BluetoothAdapter.LeScanCallback callback) {
    if (callback instanceof PeriodScanCallback) {
        ((PeriodScanCallback) callback).removeHandlerMsg();
    }
    bluetoothAdapter.stopLeScan(callback);
    if (connectionState == STATE_SCANNING) {
        connectionState = STATE_DISCONNECTED;
    }
}
 
开发者ID:qiu-yongheng,项目名称:Bluetooth_BLE,代码行数:14,代码来源:LiteBluetooth.java

示例4: getOldScanCallback

import android.bluetooth.BluetoothAdapter; //导入方法依赖的package包/类
private BluetoothAdapter.LeScanCallback getOldScanCallback() {
    return this;
}
 
开发者ID:Samsung,项目名称:microbit,代码行数:4,代码来源:PairingActivity.java

示例5: startLeScan

import android.bluetooth.BluetoothAdapter; //导入方法依赖的package包/类
/**
 * Starts a scan for Bluetooth LE devices.
 * <p/>
 * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} permission.
 *
 * @param callback the callback LE scan results are delivered (这个回调对扫描结果进行传递)
 * @return true, if the scan was started successfully
 */
public boolean startLeScan(BluetoothAdapter.LeScanCallback callback) {
    boolean suc = bluetoothAdapter.startLeScan(callback);
    if (suc) {
        connectionState = STATE_SCANNING;
    }
    return suc;
}
 
开发者ID:qiu-yongheng,项目名称:Bluetooth_BLE,代码行数:16,代码来源:LiteBluetooth.java


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