1

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.

I registered the receiver in the manifest as such:

<receiver
        android:name=".BluetoothReceiver">
        <intent-filter>
            <action android:name="android.bluetooth.device.action.ACL_CONNECTED" />

        </intent-filter>
</receiver>

And in my BluetoothReceiver class I have

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());
    }
}}

But when connecting and disconnecting from bluetooth, nothing happens. What am I doing wrong?

user2056120
  • 85
  • 3
  • 8
  • If it is for bluetooth headset, see my answer at http://stackoverflow.com/questions/14991158/using-the-android-recognizerintent-with-a-bluetooth-headset/14993590#14993590 – Hoan Nguyen Mar 08 '13 at 07:52

0 Answers0