title: How to tell if a bluetooth device is connected? My code isn't working
body: <p>I am trying to listen to the bluetooth connection/disconnection events to determine if there is a bluetooth device connected. I'm trying to do it this way so that my app will run on older android versions.</p>
  
  <p>I registered the receiver in the manifest as such:</p>
  
  <pre><code>&lt;receiver
          android:name=".BluetoothReceiver"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.bluetooth.device.action.ACL_CONNECTED" /&gt;
  
          &lt;/intent-filter&gt;
  &lt;/receiver&gt;
  </code></pre>
  
  <p>And in my BluetoothReceiver class I have</p>
  
  <pre><code>public class BluetoothReceiver extends BroadcastReceiver{
  public final static String TAG = "BluetoothReciever";
  
  public void onReceive(Context context, Intent intent)
  {
  
      Log.d(TAG, "Bluetooth Intent Recieved");
  
      final BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
      String action = intent.getAction();
  
      if (BluetoothDevice.ACTION_ACL_CONNECTED.equalsIgnoreCase(action))
      {
          Log.d(TAG, "Connected to " + device.getName());
      }
  
      if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equalsIgnoreCase(action))
      {
          Log.d(TAG, "Disconnected from " + device.getName());
      }
  }}
  </code></pre>
  
  <p>But when connecting and disconnecting from bluetooth, nothing happens. What am I doing wrong?</p>