Detect headphones Android
问题 I program in recent years to Android and I wonder something: How to detect the presence of headphones? There is a method: isWiredHeadsetOn() but it doesn't work. I've tried that but it doesn't work: AudioManager am = (AudioManager)getSystemService(AUDIO_SERVICE); Log.i("am.isWiredHeadsetOn()", am.isWiredHeadsetOn() + ""); if (am.isWiredHeadsetOn()) { //code } Thank you (and sorry if I made spelling mistakes, I am French) 回答1: @Phil answer at https://stackoverflow.com/a/19102661/4758255 is a