Change notification sound using AccessibilityService

152 views Asked by At

I have implemented an accessibility service that listens to notifications and is notified whenever a notification is triggered.
My question is: once I obtain the Notification object, can I set its sound to a custom sound?
I tried doing something like:

notification.sound = Uri.parse("<path_to_custom_sound>");

but this does not work.
Is there a way to do this?

1

There are 1 answers

1
ravi On

This might help you.

notification.sound = Uri.parse("android.resource://" + getPackageName() + "/" R.raw.notifysnd);
notification.defaults = Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE;