title: Android 6.0 Bluetooth Program Cannot Discover Any Available Bluetooth Devices
body: <p><strong>GOAL</strong> </p>
  
  <p>Discovering all the available bluetooth devices such as my iPad with bluetooth ON (Discoverable).
  <br><br></p>
  
  <p><strong>ANDROID VERSION</strong></p>
  
  <p>6.0
  <br><br></p>
  
  <p><strong>PROBLEM</strong></p>
  
  <p>Cannot Discover any bluetooth devices.
  <br><br></p>
  
  <p><strong>CODE</strong></p>
  
  <pre><code>// Permission
  &lt;uses-permission android:name="android.permission.BLUETOOTH" /&gt;
  &lt;uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /&gt;
  
  public BroadcastReceiver mReceiver;
  public IntentFilter filter;
  
  private boolean discover_AvailableBluetoothDevice() {
          mReceiver = new BroadcastReceiver() {
              public void onReceive(Context context, Intent intent) {
                  Log.d(TAG, "onReceive Called");
                  String action = intent.getAction();
                  // When discovery finds a device
                  if (BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(action)) {
                      Log.d(TAG, "ACTION_DISCOVERY_STARTED");
                  } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
                      Log.d(TAG, "ACTION_DISCOVERY_FINISHED");
                  } else if (BluetoothDevice.ACTION_FOUND.equals(action)) {
                      Log.d(TAG, "ACTION_FOUND");
                      // Get the BluetoothDevice object from the Intent
                      BluetoothDevice device = (BluetoothDevice) intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
                      // Add the name and address to an array adapter to show in a ListView
                      String str = device.getName() + "\n( " + device.getAddress() + " )";
                      adapter.add(str);
                  }
              }
          };
  
          filter = new IntentFilter();
          filter.addAction(BluetoothDevice.ACTION_FOUND);
          filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_STARTED);
          filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
          registerReceiver(mReceiver, filter);
          boolean isSuccessDiscovery = mBluetoothAdapter.startDiscovery();
          return isSuccessDiscovery;
      }
  </code></pre>
  
  <p><br><br></p>
  
  <p><strong>EXECUTION RESULT (logcat)</strong></p>
  
  <pre><code>02-02 01:17:26.142 7194-7194/eie.imt.smartswitch D/†MainActivity: This device support Bluetooth.
  02-02 01:17:55.052 7194-7194/eie.imt.smartswitch D/†ConnectSwitchActivity: isSuccessDiscovery=true
  02-02 01:17:55.147 7194-7194/eie.imt.smartswitch D/†ConnectSwitchActivity: onReceive Called
  02-02 01:17:55.147 7194-7194/eie.imt.smartswitch D/†ConnectSwitchActivity: ACTION_DISCOVERY_STARTED
  02-02 01:18:07.909 7194-7194/eie.imt.smartswitch D/†ConnectSwitchActivity: onReceive Called
  02-02 01:18:07.910 7194-7194/eie.imt.smartswitch D/†ConnectSwitchActivity: ACTION_DISCOVERY_FINISHED
  </code></pre>
  
  <p>I see the program does not enter the condition block of <strong>ACTION_FOUND</strong> but my iPad's bluetooth is ON, where does the problem come from?</p>