阅读背景:

android 蓝牙BLE多连接

来源:互联网 

//扫描ble 设备
private class ScanLeTask extends AsyncTask<Void, Void, Void> {@Overrideprotected Void doInBackground(Void... params) {manager.scanLeDevice(true, mLeScanCallback);return null;}}// Device scan callback.private BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback() {@Overridepublic void onLeScan(final BluetoothDevice device, int rssi,byte[] scanRecord) {runOnUiThread(new Runnable() {@Overridepublic void run() {Log.d(TAG, device.getName());BtDevice mDevice = new BtDevice(device.getAddress(),device.getName());if (!mList.contains(mDevice)) {mList.add(mDevice);View view = getLayoutInflater().inflate(R.layout.deviceitem, null);view.setTag(mList.size() - 1);TextView textView = (TextView) view.findViewById(R.id.name);Button button = (Button) view.findViewById(R.id.icon);button.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {View view = (View) v.getParent();int index = (Integer) view.getTag();manager.connect(mList.get(index).getAddr(),index);Log.d(TAG, "index is:" + index);}});textView.setText(mDevice.getName());container.addView(view);}}});}};private class ScanLeTask extends AsyncT



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: