【发布时间】:2017-12-13 07:01:36
【问题描述】:
我的 Android 应用程序有 Firebase 消息传递。我正在使用 Firebase 发送推送通知。我想将默认通知声音更改为自定义声音。我该怎么做 ?
Uri defaultSoundUri =
RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setLargeIcon(image)/*Notification icon image*/
.setSmallIcon(R.mipmap.ic_notif)
.setContentTitle(title)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent)
.setCustomBigContentView(remoteViews)
.setStyle(new NotificationCompat.BigPictureStyle().bigPicture(image))
;
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(Integer.parseInt(id) /* ID of notification */, notificationBuilder.build());
}
【问题讨论】:
-
你可以找到this的文章非常有用。它解释了如何处理自定义声音。
标签: android firebase notifications firebase-cloud-messaging