Uri de son par défaut de notification?
- Je utiliser le La Notification.Constructeur de construire une notification.
Maintenant je veux utiliser le son par défaut de notification avec:
builder.setSound(Uri sound)
Mais où est l'Uri de la notification par défaut?
Vous devez vous connecter pour publier un commentaire.
essayez d'utiliser RingtoneManager pour obtenir de Notification par Défaut Uri comme:
Settings.System.DEFAULT_NOTIFICATION_URI
builder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI)
fonctionne aussi bienLes deux options à utiliser les
Default Notification Sound
sont:ou à l'aide de RingtoneManager Classe:
toutes ces méthodes de travail
mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
mBuilder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI);
mBuilder.setDefaults(Notification.DEFAULT_SOUND);
Google Documents
Vous pouvez l'utiliser ainsi:
application
son du canal pas par défaut du système sonore essayé avecNotificationChannel channel = new NotificationChannel(ApplicationClass.getInstance().HighNotificationChannelID, getString(R.string.incoming_sms), NotificationManager.IMPORTANCE_HIGH); channel.getSound();
retournedefault system sound
s'il vous plaît aiderUri Uri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Uri customSoundUri = Uri.parse("android.resource://" + getPackageName() + "/" + R. raw.twirl);
https://notificationsounds.com/message-tones/twirl-470
Si quelqu'un a encore besoin, cela fonctionne tout à fait bien avec le son et les vibrations.
Si vous souhaitez désactiver par exemple les vibrations de changement de vibrer à nouveau long[] { 0,0,0,0,0};
Presque semblable chose que vous pouvez faire avec son ou utiliser l'instruction if else.