2

I need to have some custom behavior in my app when the audio playback is done on the device speaker (not a wired headphone and not a BlueTooth receiver). To do so I'm doing the following

    AudioManager audioManager = (AudioManager) service.getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
    isSpeakerPhoneOn = audioManager.isSpeakerphoneOn();

But isSpeakerPhoneOn is always false. By the way, I'm calling the code after playback is started.

Any idea what I'm doing wrong?

balumn
  • 113
  • 1
  • 5
user1026605
  • 1,633
  • 4
  • 22
  • 58

1 Answers1

1

I suggest you to try this

AudioManager manager = (AudioManager)this.getSystemService(Context.AUDIO_SERVICE);
if(manager.isMusicActive())
 {
     // do something - or don't
 }
Jamal Alkelani
  • 606
  • 7
  • 19