1

I'm not sure if this is possible, but I'm trying to get the name (or some sort of identifier) of the device that is plugged into the my phone's audio jack programmatically. The device is not a headset or any type of headphones, so I need a way to distinguish it from those types of devices. I detect if a device is plugged into the audio jack by doing:

public class DetectAudioDevice extends BroadcastReceiver {

    private final int HEADSET_UNPLUGGED = 0;
    private final int HEADSET_PLUGGED   = 1;

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals(Intent.ACTION_HEADSET_PLUG)) {
            int state = intent.getIntExtra("state", -1);
            switch (state) {
                case HEADSET_UNPLUGGED:
                    log("Headset unplugged!");
                    break;
                case HEADSET_PLUGGED:
                    log("Headset plugged!");
                    // Check device's name
                    break;
             }
        }
    }
}

EDIT: Found what I'm looking for here.

Community
  • 1
  • 1
Ivan
  • 665
  • 2
  • 10
  • 28

0 Answers0