2

My app needs to know early on at onCreate() whether the headset is plugged in or not (if it isn't, it should simply display a dialog and exit, as this is a headset-only app, not to be used with a speaker).

Because registering a receiver for ACTION_HEADSET_PLUG or ACTION_AUDIO_BECOMING_NOISY is recommended to be done in either onStart() or onResume(), relying on these messages in onCreate is out of question.

So, I turned instead to Audio Manager's isSpeakerphoneOn() with the hope that my app's onCreate() will find it reflecting the correct status of the speakerphone.

Unfortunately however, isSpeakerphoneOn() always return false, despite the speakerphone being on and nothing else plugged in (neither wired nor bluetooth headset).

My questions are:

  1. Why? What are the conditions for this isSpeakerphoneOn() method to correctly reflect the phone's status?

    1. Is there a way to determine in onCreate() whether the headset is plugged in or not?
WebViewer
  • 761
  • 7
  • 21
  • This [SO thread](http://stackoverflow.com/a/12508703/5556250) suggests that you are out of luck. There simply isn't adequate support for this in the current Android API. – Jay Souper Feb 05 '17 at 09:44

0 Answers0