• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps How do you use ACTION_HEADSET_PLUG?

bluebrian

Lurker
Nov 10, 2012
1
0
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
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones