當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。