Android - 管理通知
Android - Manage the notifications
我想为用户创建一些通知。
例如:当有新评论时,当有人提问时,...
我知道如何创建通知,但我不知道如何只发送一次通知。
示例:通知发送给用户,因为他有新评论。他点击开始申请的通知并观看评论。但是现在,我怎样才能避免它收到两次相同的通知呢?
建议将其存储在数据库中,在 "notification" table 中,或者存在用于管理它的系统?
对不起,我的英语很糟糕。
你看过Google云消息吗?
https://developers.google.com/cloud-messaging/android/start
如果您已经实现了这一点,并且收到了两次相同的通知,这可能与您构建通知的方式有关。如果以上 link 没有帮助,您能否 post 更多信息,可能还有代码?
我通过检查通知是否已经显示来解决了问题。
private boolean isNotificationVisible() {
Intent notificationIntent = new Intent(context, MainActivity.class);
PendingIntent test = PendingIntent.getActivity(context, MY_ID, notificationIntent, PendingIntent.FLAG_NO_CREATE);
return test != null;
我想为用户创建一些通知。 例如:当有新评论时,当有人提问时,... 我知道如何创建通知,但我不知道如何只发送一次通知。 示例:通知发送给用户,因为他有新评论。他点击开始申请的通知并观看评论。但是现在,我怎样才能避免它收到两次相同的通知呢? 建议将其存储在数据库中,在 "notification" table 中,或者存在用于管理它的系统?
对不起,我的英语很糟糕。
你看过Google云消息吗?
https://developers.google.com/cloud-messaging/android/start
如果您已经实现了这一点,并且收到了两次相同的通知,这可能与您构建通知的方式有关。如果以上 link 没有帮助,您能否 post 更多信息,可能还有代码?
我通过检查通知是否已经显示来解决了问题。
private boolean isNotificationVisible() {
Intent notificationIntent = new Intent(context, MainActivity.class);
PendingIntent test = PendingIntent.getActivity(context, MY_ID, notificationIntent, PendingIntent.FLAG_NO_CREATE);
return test != null;