How to set type to my audio so it will be treated like a call?

348 Views Asked by At

I'm making VoIP app on Android, playing PCM audio like in Play PCM stream in Android

On my phone (LG V20, Android8) it works, but when I'm using volume buttons, it doesn't show Call volume and volume control doesn't work for my audio at all.

How to make my audio "Call audio" and be controlled by standard volume controls?

2

There are 2 best solutions below

0
On BEST ANSWER

In the end, I was missing:

  1. Permission - MODIFY_AUDIO_SETTINGS
  2. Setting AudioManager mode to MODE_IN_COMMUNICATION

I'm surprised it wasn't in tutorials, maybe it was changed in later SDK.

1
On

You have to take AudioFocus by calling "requestAudioFocus()": https://developer.android.com/reference/android/media/AudioManager#requestAudioFocus(android.media.AudioFocusRequest) and set VOICECALL Stream in the Constructor of the Request.