Delphi Firemonkey – Assigning Custom Alert to Notification Channel in Android


I’m trying to create a set of notification channels with custom alerts so end users can identify the type of alert from audio alone. The handsets we’re targeting are all Android 8 or greater, and thus assigning
Notification.Soundname := <path here>

No longer functions, and the notification plays the default sound for the channel.
Furthermore, on channel creation, there is no sound property or variable to assign.
I’ve been trawling through the JNI units supplied with Delphi 10.4.1 and in Androidapi.JNI.App.pas, lines 1797, 1805, 1816 there is this code:
//function getAudioAttributes: JAudioAttributes; cdecl;
//function getSound: Jnet_Uri; cdecl;
//procedure setSound(sound: Jnet_Uri; audioAttributes: JAudioAttributes); cdecl;

Which sounds like exactly what I’m looking for, but uncommenting this code and adding Androidapi.JNI.Media into the uses clause for the unknown types ends in a circular reference.
How can I achieve my goal?

Comments are closed.