启动多个Notification

case SEND_FAILD:
if(notificationsHelp!= null)
{
Log.e("msg", "SEND_FAILD");
notificationsHelp.endNotification(ID_SEND);

try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

notificationsHelp = new NotificationsHelp(getApplicationContext(), R.drawable.at_normal, "发送失败", System.currentTimeMillis());
Intent notificationIntent = new Intent(NewWeiBoSendService.this, NewWeiBoSendService.class);
Bundle bundle = new Bundle();
bundle.putString("content", content);
bundle.putString("pictureUrl", pictureUrl);
bundle.putString("postUrl", postUrl);
notificationIntent.putExtras(bundle);
PendingIntent contentIntent = PendingIntent.getService(NewWeiBoSendService.this, ID_SEND_FAIL, notificationIntent,PendingIntent.FLAG_UPDATE_CURRENT);
notificationsHelp.startNotification(ID_SEND_FAIL, "发送微博", (String)msg.obj, contentIntent);
notificationsHelp.setCancelAuto();
}

break;


要在状态栏上显示多个Notification,要注意一下几点

 1. notificationsHelp.startNotification(ID_SEND_FAIL, "发送微博", (String)msg.obj, contentIntent);  ID_SEND_FAIL 要不同

2. PendingIntent contentIntent = PendingIntent.getService(NewWeiBoSendService.this, ID_SEND_FAIL, notificationIntent,PendingIntent.FLAG_UPDATE_CURRENT);

     第四个参数 PendingIntent.FLAG_UPDATE_CURRENT 能每次传递新的数据

   第二个参数 ID_SEND_FAIL 即使没用到,但是假如是相同的ID会覆盖之前的Intent


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值