AudioManager.isWiredHeadsetOn() is not working in android
Asked Answered
O

1

6

I want to check whether heaset is plugged in or not... I did it like this

 AudioManager am = (AudioManager)getSystemService(AUDIO_SERVICE);
 Log.i("am.isWiredHeadsetOn()", am.isWiredHeadsetOn()+"");

But i am always getting false value...

Why is this happening?

Oldtimer answered 6/6, 2011 at 9:18 Comment(5)
Are you testing this on the emulator or an actual device? And what Android OS do you have on the emulator or device?Phelips
I am testing this on Folio 100 Tablet and it has Android 2.2Oldtimer
This actually should work fine. Can you check your code on other devices then Folio 100?Nadenenader
Yes i also have checked it on HTC wildfire too and it is giving false.. Is there any permission that i need to add?Oldtimer
It looks like it should work fine. Are you sure the AudioManager is working properly? Try playing a sound using it like: am.playSoundEffect(FX_KEY_CLICK);Phelips
N
13

It looks like this is a bug. You will always get false when calling isWiredHeadsetOn unless your add MODIFY_AUDIO_SETTINGS permission to AndroidManifest.xml:

<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
Nadenenader answered 6/6, 2011 at 9:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.