title: How to discover Bluetooth devices Programatically in android and display in Listview
body: <p>I tried and followed some tutorial on web but it didn't work on new Android versions.</p>
  
  <p>I declared all Bluetooth permissions and used Dexter permission library. I followed few answers but it doesn't display available Bluetooth device name also</p>
  
  <p>Below is my code:</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
      scan.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              toast("starts scanning...");
              mBluetoothAdapter.startDiscovery();
  
          }
      });
  
      mAdapter = new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_1);
      mListView.setAdapter(mAdapter);
  
      mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int i, long l) {
             String bluetoothDevice = mAdapter.getItem(i);
             toast(bluetoothDevice);
          }
      });
  
  }
  public void pairedDevicesListView(View view){
      mAdapter.clear();
  
      pairedDevices = mBluetoothAdapter.getBondedDevices();
  
      for (BluetoothDevice device : pairedDevices){
          mAdapter.add(device.getName() + "\n" + device.getAddress());
  
      }
  }
  }
  </code></pre>