0

I have recently purchased a pressy button and I try a few things with it. I am able to listen for pressy clicks using a media_button receiver.

However I noticed that when I plug the pressy button into the device headphones slot, and then I try to make a call, the dial clicks sounds are gone. Most likely the device is acting like the headphones are connected, so sound does not go to speakers.

I have found this post : enter link description here

but the solution there is not suitable for me, because if I force audio to mode_call, then my receiver is no longer receiving pressy clicks.

I know this is possible because there is an app on playstore, Klick, that is able to do this.

Anyone can help me? Thank you

Community
  • 1
  • 1
Mihai si atat
  • 170
  • 2
  • 13

1 Answers1

0

I have found a solution, but I noticed that sometimes on a Samsung device it has no effect. Then suddenly the sound is played in device speakers when headphones are plugged.

AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
        am.registerMediaButtonEventReceiver(new ComponentName(getPackageName(), BroadcastReceiverPressyButton.class.getName()));

// Force audio through the speakers when pressy button is plugged in
am.setMode(AudioManager.MODE_IN_COMMUNICATION);
am.setSpeakerphoneOn(true);
Mihai si atat
  • 170
  • 2
  • 13