IntentFilter intentFilter = new IntentFilter(BluetoothDevice.ACTION_FOUND); BluetoothDemo.this.registerReceiver(myReceiver, intentFilter); bluetoothAdapter.startDiscovery();
discoveryStartConfirmed = false; LogManager.d(TAG, "about to command discovery"); if (!adapter.startDiscovery()) { LogManager.w(TAG, "Can't start discovery. Is Bluetooth turned on?");
/** * discovery the devices. * * @param listener listener for the process */ public void searchDevices(OnSearchDeviceListener listener) { checkNotNull(listener); if (mBondedList == null) mBondedList = new ArrayList<>(); if (mNewList == null) mNewList = new ArrayList<>(); mOnSearchDeviceListener = listener; if (mBluetoothAdapter == null) { mOnSearchDeviceListener.onError(new NullPointerException(DEVICE_HAS_NOT_BLUETOOTH_MODULE)); return; } if (mReceiver == null) mReceiver = new Receiver(); // ACTION_FOUND IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND); mContext.registerReceiver(mReceiver, filter); // ACTION_DISCOVERY_FINISHED filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED); mContext.registerReceiver(mReceiver, filter); mNeed2unRegister = true; mBondedList.clear(); mNewList.clear(); if (mBluetoothAdapter.isDiscovering()) mBluetoothAdapter.cancelDiscovery(); mBluetoothAdapter.startDiscovery(); if (mOnSearchDeviceListener != null) mOnSearchDeviceListener.onStartDiscovery(); }
/** * Start device discovery. (keep discovering for about 12s) * The device discovered will be sent as broadcast. * * @return true on success, false on error */ public boolean startDiscovery() { return bluetoothAdapter.startDiscovery(); }
/** * Start the remote device discovery process. * * @return true on success, false on error */ public boolean startDiscovery() { return bluetoothAdapter.startDiscovery(); }
/** * 搜索蓝牙设备 */ public static void searchDevices(BluetoothAdapter adapter) { // 寻找蓝牙设备,android会将查找到的设备以广播形式发出去 if (null != adapter) { adapter.startDiscovery(); } }
public boolean startDiscovery() { return mBluetoothAdapter.startDiscovery(); }
/** * Api11+都可以使用的蓝牙扫描 */ private void doDiscovery() { bluetoothAdapter.cancelDiscovery(); bluetoothAdapter.startDiscovery(); }
protected void proceedDiscovery() { IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND); filter.addAction(BluetoothDevice.ACTION_NAME_CHANGED); registerReceiver(mBTReceiver, filter); mBluetoothAdapter.startDiscovery(); }
@Override public void run() { Toast.makeText(getApplicationContext(), "Cannot establish connection", Toast.LENGTH_SHORT).show(); mBluetoothAdapter.startDiscovery(); } };
@Override public void onItemSelectorDialogRefreshList(ItemSelectorDialog<DeviceItem> itemSelectorDialog) { if (okToStartDiscovery && btAdapter != null && !connecting && this.itemSelectorDialog != null && this.itemSelectorDialog == itemSelectorDialog) { try { btAdapter.startDiscovery(); } catch (Throwable ex) { ex.printStackTrace(); return; } itemSelectorDialog.showProgressBar(true); okToStartDiscovery = false; } }
/** * do discovery */ public void doDiscovery() { if (D) Log.d(TAG, "doDiscovery()"); // If we're already discovering, stop it if (mBluetoothAdapter.isDiscovering()) { mBluetoothAdapter.cancelDiscovery(); } // Request discover from BluetoothAdapter mBluetoothAdapter.startDiscovery(); }
@Override public void onSuccess() { // Step 4: Scan for Bluetooth device mBluetoothReceiver = new BluetoothReceiver(); context.registerReceiver(mBluetoothReceiver, new IntentFilter(BluetoothDevice.ACTION_FOUND)); mBluetoothAdapter.startDiscovery(); // sleep(10000); sleep(searchTime); mBluetoothAdapter.cancelDiscovery(); context.unregisterReceiver(mBluetoothReceiver); }
@Override public boolean startScan() { if (!isAvailable() && !isEnabled()){ return false; } return mBluetoothAdapter.startDiscovery(); }
@Override public void onClick(View v) { if (mBluetoothAdapter.isDiscovering()) { mBluetoothAdapter.cancelDiscovery(); } else { mBluetoothAdapter.startDiscovery(); mDataList.clear(); mAdapter.notifyDataSetChanged(); } } });
@Override protected void onResume() { super.onResume(); // Garante que não existe outra busca sendo realizada if(btfAdapter != null) { if (btfAdapter.isDiscovering()) { btfAdapter.cancelDiscovery(); } // Dispara a busca btfAdapter.startDiscovery(); dialog = ProgressDialog.show(this, "Exemplo", "Buscando dispositivos bluetooth...", false, true); } }
public void reScan() { mDevices.clear(); addBound(); BluetoothAdapter bt = BluetoothAdapter.getDefaultAdapter(); if (!bt.isDiscovering()) bt.startDiscovery(); notifyDataSetChanged(); }
private void startDiscovery() { if (bluetoothAdapter.isDiscovering()) { bluetoothAdapter.cancelDiscovery(); } bluetoothAdapter.startDiscovery(); initiateScanDevices.setEnabled(false); }
public void startDiscovery() { if (getDefaultAdapter() != null) { if (getDefaultAdapter().isDiscovering()) { getDefaultAdapter().cancelDiscovery(); } Log.i(TAG, "Starting Bluetooth discovery"); getDefaultAdapter().startDiscovery(); } }