TL;DR how to start a notification in a channel that has a sound but play the actual sound with a MediaPlayer?
I work on an Android calling app. The incoming calls are displayed via full screen intent notifications. Notifications are dispatched to a channel with a sound and vibration.
I came across an issue on OnePlus devices with their "pocket mode". Basically if you put your phone into the pocket and receive a call via a notification, the pocket mode will silence it (i.e. you don't hear the ringing).
This does not happen if I play the ringtone with a MediaPlayer.
Now, the question is how to avoid the notification and the MediaPlayer play at the same time. I m certain that this is possible because Signal does it. But I fail to understand how they do it. They create their channels the normal way and the incoming call notification is built the same way I tried.
For some reason once the notification is displayed it does not emit any sound nor vibration.
Does anyone have a clue how they managed to do it?
P.S.: I tried to use setSilent(true)
on my notification but in this case the system does not display the notification at all, it launches the full screen intent immediately.
N.b.: I checked all stackoverflow issues that resembled even remotely what I am trying to figure out. Those that matched the description never got a meaningful answer.