【问题标题】:Latest local notification overrides the previous one最新的本地通知覆盖前一个
【发布时间】:2019-03-08 13:14:37
【问题描述】:

我使用 Call 操作创建本地通知。通知使用以下代码触发,每个通知都有不同的通知 ID:

Intent myIntent = new Intent(mContext, NotificationService.class);
    myIntent.putExtra("phoneNumber", phone);
    myIntent.putExtra("notificationId", notificationId);

AlarmManager alarmManager = (AlarmManager) mContext.getSystemService(ALARM_SERVICE);
            PendingIntent pendingIntent = PendingIntent.getService(mContext, notificationId, myIntent, PendingIntent.FLAG_UPDATE_CURRENT);
            alarmManager.set(AlarmManager.RTC_WAKEUP, startTime, pendingIntent);

NotificationService.class 我创建并显示通知 notificationManager.notify(notificationId, mBuilder.build());

我以几秒钟的间隔触发两个通知,并且两者都在状态栏中可见。 假设第一个必须对 1111 进行呼叫操作,而第二个必须对 2222 进行呼叫操作。 如果我按下第一个呼叫操作,它将呼叫 2222。有什么问题?

【问题讨论】:

  • 发布来自Service的代码,获取“附加”并拨打电话。

标签: android android-notifications android-pendingintent android-alarms


【解决方案1】:

我想删除标志 PendingIntent.FLAG_UPDATE_CURRENT 会有所帮助:

PendingIntent pendingIntent = PendingIntent.getService(
        mContext, notificationId, myIntent, 0);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-23
    • 1970-01-01
    • 2017-02-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多