更新时间:2022-06-11 00:15:29
在 http://developer.android.com/guide/topics/ui/notifiers/notifications.html有这个注释:
注意:如果 defaults 字段包含 DEFAULT_SOUND,则默认声音会覆盖声字段定义的任何声音.
Note: If the defaults field includes DEFAULT_SOUND, then the default sound overrides any sound defined by the sound field.
所以,如果你只想自定义声音,你可以使用 -
So, if you want to customize only sound, you may use -
notification.sound = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.notifysnd);
notification.defaults = Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE;