Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

New Forums: Nexus Player | Nexus 9
test: Reply
LinkBack Thread Tools
Old November 10th, 2012, 06:27 PM   #1 (permalink)
New Member
Thread Author (OP)
Join Date: Nov 2012
Posts: 1
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default How do you use ACTION_HEADSET_PLUG?

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" >
<action android:name="android.intent.action.HEADSET_PLUG" >

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


bluebrian is offline  
Reply With Quote
sponsored links
Old November 14th, 2012, 02:54 PM   #2 (permalink)
Senior Member
jonbonazza's Avatar
Join Date: Jul 2010
Gender: Male
Posts: 1,935
Device(s): Nexus 4, Samsung Galaxy S II, HTC Evo 4G, Amazon Kindle Fire
Carrier: ATT

Thanks: 235
Thanked 482 Times in 294 Posts

What level of the manifest did you place the above code?
My blog, Inverted Keystrokes, is looking for aspiring developers (not necessarily with Android) to post articles. If you have any development experience and are interested in participating, please PM me. =)
jonbonazza is offline  
Reply With Quote
android, audio, broadcastreceiver, eclipse, headset, jack

Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

All times are GMT -5. The time now is 08:01 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.