【发布时间】:2015-10-29 10:46:48
【问题描述】:
我会收听诸如 WhatsApp 消息之类的通知。
但每次通知进入 NotificationListenerService 时都会触发两次。
有人知道这个问题吗?
这是来自 AndroidManifest.xml 的 sn-p:
<service android:name=".NotifyService"
android:label="WhatsNotify"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
<intent-filter>
<action android:name="android.service.notification.NotificationListenerService"></action>
</intent-filter>
</service>
在 NotificationListenerService 类内部:
public class NotifyService extends NotificationListenerService {
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
Log.i("NotifyService", "got notification");
}
}
编辑:
StatusBarNotifications 的两个属性:
第一次通知:
0|com.whatsapp|1|xxxxxxxxxx@s.whatsapp.net|10073
第二次通知:
0|com.whatsapp|1|null|10073
【问题讨论】:
-
你有这个prob的解决方案吗
-
@BhanuSharma 不。我的解决方案是创建一个新的 android 项目,然后它就可以工作了。
-
是指你在新项目中写的相同代码,它会自动正常运行吗?
-
你解决了这个问题吗,因为我收到这个错误直到日期
-
您的问题与群组摘要通知有关。见:stackoverflow.com/a/55365244/1658621
标签: android android-notifications android-notification-bar