我正在从服务器向设备发送推送通知,但在某些设备中,即使邮件仅发送一次,通知声音也会响铃多次。
在三星,小米和华硕,它运作正常,但在LG Marshmallow,声音响了不止一次。
这是我的代码:
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
inboxStyle.addLine(message);
Notification notification;
notification = mBuilder
.setPriority(Notification.PRIORITY_MAX)
.setSmallIcon(R.drawable.iconnotif)
.setTicker(message)
.setAutoCancel(true)
.setContentTitle(title)
.setContentIntent(resultPendingIntent)
.setSound(Settings.System.DEFAULT_NOTIFICATION_URI)
.setStyle(inboxStyle)
.setSmallIcon(R.drawable.iconnotif)
.setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), icon))
.setContentText(message)
.build();
PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "TAG");
wl.acquire(15000);
NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notification);
请帮忙。感谢。