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();
}
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