Android推送通知声音在某些设备(LG)中不止一次响铃

时间:2017-02-16 03:22:07

标签: android firebase push-notification firebase-cloud-messaging

我正在从服务器向设备发送推送通知,但在某些设备中,即使邮件仅发送一次,通知声音也会响铃多次。

在三星,小米和华硕,它运作正常,但在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);

请帮忙。感谢。

0 个答案:

没有答案