yay*_*wei 2 android push-notification android-c2dm
我每半小时向我的Android应用发送一次C2DM更新,这会创建一个通知.问题是,当我早上醒来时,我在状态栏中排队了15个通知.
我如何只保留最新通知,覆盖以前的通知?
我试着查看C2DM文档(http://code.google.com/android/c2dm/),其中提到了一个名为collapse_key的参数,但我找不到如何使用它的解释,也不确定解决方案位于C2DM方面.
谢谢!
如果要取消在视图上设置的任何先前通知,可以尝试设置其中一个标志.
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_UPDATE_CURRENT
Run Code Online (Sandbox Code Playgroud)
这样的事情应该取代我相信的旧通知
NotificationManager mManager= (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Intent intent = new Intent(this,test.class);
Notification notification = new Notification(R.drawable.icon, "Notify", System.currentTimeMillis());
notification.setLatestEventInfo(this,"App Name","Description of the notification",
PendingIntent.getActivity(this.getBaseContext(), 0, intent, PendingIntent.FLAG_CANCEL_CURRENT));
mManager.notify(0, notification);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6868 次 |
| 最近记录: |