1. Download our Official Android App: Forums for Android!

Apps How do you use ACTION_HEADSET_PLUG?

Discussion in 'Android Development' started by bluebrian, Nov 10, 2012.

  1. bluebrian

    bluebrian Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    1
    Joined:
    Nov 10, 2012

    Nov 10, 2012
    1
    0
    5
    I am working on an android application and I want to detect whether the headset is plugged in or not. I found the ACTION_HEADSET_PLUG thing, but I don't understand how to use it, and everything I have tried has not worked yet.

    I tried adding
    <receiver android:enabled="true" android:name=".AudioJackReceiver" >
    <intent-filter>
    <action android:name="android.intent.action.HEADSET_PLUG" >
    </action>
    </intent-filter>
    </receiver>

    To my manifest, and I made a class that extends BroadcastReceiver in my package, but it doesn't seem to be called.
    Do I need to add a special permission to my manifest? Can anyone point me to a sample application that uses this? I couldn't find anything in ApiDemos.

    Any help would be appreciated

    Thanks
     

    Advertisement

  2. jonbonazza

    jonbonazza Android Expert
    Rank:
    None
    Points:
    163
    Posts:
    1,930
    Joined:
    Jul 13, 2010

    Jul 13, 2010
    1,930
    457
    163
    Male
    What level of the manifest did you place the above code?
     

Share This Page

Loading...