我已经升级target build version
到27
所以需要实施notification channel
。我正在启动一个前台service
,它将在启动时显示一个通知。使用通知通道,它可以按预期工作,但始终是make sound
. 更改通知priority
没有任何效果。
if(Build.VERSION.SDK_INT >= 26) {
NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID,
CHANNEL_NAME, NotificationManager.IMPORTANCE_LOW);
mNotificationManager.createNotificationChannel(notificationChannel);
notification = new Notification.Builder(this,CHANNEL_ID)
.setContentTitle("My App")
.setContentText(status)
.setSmallIcon(R.drawable.ic_stat_notify)
.setContentIntent(pendingIntent)
.build();
}
我查过了,IMPORTANCE_MIN
一切都在发出声音IMPORTANCE_DEFAULT
IMPORTANCE_LOW