Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. private final BroadcastReceiver devicesFoundReceiver = new BroadcastReceiver() {
  2. @Override
  3. public void onReceive(Context context, Intent intent) {
  4. String action = intent.getAction();
  5. if (BluetoothDevice.ACTION_FOUND.equals(action)) {
  6. BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
  7. listAdapter.add(device.getName() + "\n" + device.getAddress());
  8. //mList.add(device.getName());
  9.  
  10. for (int i = 0; i < listAdapter.getCount(); i++) {
  11. String str = listAdapter.getItem(i);
  12. mList.add(str);
  13. Log.d("Name", str);
  14. }
  15. listAdapter.notifyDataSetChanged();
  16. } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
  17. btnScan.setText("Scanning Bluetooth devices...");
  18. } else if (BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(action)) {
  19. btnScan.setText("Scanning in progress...");
  20. }
  21. }
  22. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement