I am writing application which intented to replace standard/stock messenger. So I need to define default ringtone for incoming messages. I mean incoming SMS notification ringtone.
Anyone knows how to get it?
I am writing application which intented to replace standard/stock messenger. So I need to define default ringtone for incoming messages. I mean incoming SMS notification ringtone.
Anyone knows how to get it?
For default notification sound :
String defaultPath = Settings.System.DEFAULT_NOTIFICATION_URI.getPath();
To retrieve the Ringtone
object of the default ringtone, use the RingtoneManager
:
Ringtone ringtone = RingtoneManager.getRingtone(context, Settings.System.DEFAULT_RINGTONE_URI);
If the user has changed the default ringtone to a ringtone provided in a 3rd party messager app, AFAIK you can't access the new ringtone unless the 3rd party app exposes its ringtones via a ContentProvider
.
For default notification sound :
String defaultPath = Settings.System.DEFAULT_NOTIFICATION_URI.getPath();
If you are using the Notification.Builder
or NotificationCompact.Builder
classes, calling setSound(Settings.System.DEFAULT_NOTIFICATION_URI)
on the builder should do the trick.
That will play the default Notification tone that the user has picked when the system displays your notification.
The one that helped me is
RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
.
© 2022 - 2024 — McMap. All rights reserved.