पर अधिसूचना ध्वनि मेरे पास एक कस्टम एमपी 3 ध्वनि है जिसे मैं अपनी सूचनाओं पर उपयोग करता हूं। यह एपीआई 26 के नीचे सभी उपकरणों पर ठीक काम करता है। मैंने अधिसूचना चैनल पर भी ध्वनि सेट करने की कोशिश की, लेकिन अभी भी कोई काम नहीं है। यह डिफ़ॉल्ट ध्वनि बजाता है।एपीआई 26
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, channelId)
.setAutoCancel(true)
.setSmallIcon(R.drawable.icon_push)
.setColor(ContextCompat.getColor(this, R.color.green))
.setContentTitle(title)
.setSound(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.notification))
.setDefaults(Notification.DEFAULT_VIBRATE)
.setStyle(new NotificationCompat.BigTextStyle().bigText(message))
.setContentText(message);
Notification notification = builder.build();
NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_DEFAULT);
AudioAttributes audioAttributes = new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
.build();
channel.setSound(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.notification), audioAttributes);
notificationManager.createNotificationChannel(channel);
}
notificationManager.notify(1, notification);
क्या आपने डिफ़ॉल्ट अधिसूचना ध्वनि म्यूट किया था? मुझे भी एक ही समस्या का सामना करना पड़ रहा है। मैं NotificationManager.IMPORTANCE_MAX के साथ अधिसूचना पर कोई भी स्वर नहीं खेलना चाहता हूं। क्या आप कृपया इसमें मेरी मदद कर सकते हैं। –