我有一个正在进行的后台下载文件的通知。我已成功创建多个同时更新进度栏通知,这些通知也可以取消。这在所有测试设备上都能正常工作,除了一些最近使用Honeycomb的Android平板电脑。Android蜂窝上的持续通知具有不一致的行为
现在,原始通知消息不断重新显示,防止用户点击时钟以显示正在进行的通知列表。因此,甚至没有看到进度条。有没有人成功地在Honeycomb上创建进度条通知?
作为一方,我还发现我的黑色通知文本在通知列表的黑色背景中不再可读。有没有为蜂窝设备设置白色文本的方法?
注:这一问题已经在运行Android 3.0.1的擎天柱垫L-06C和摩托罗拉XOOM
下面测试是通知创造
// Create new notification for downloading
mNotification = new Notification(R.drawable.owl_icon, getNotificationText(R.string.notification_content_downloading), 0);
mNotification.flags |= (Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT);
// Create custom progress bar view
RemoteViews contentView = new RemoteViews(CourseSyncService.this.getPackageName(), R.layout.notification_downloading);
contentView.setTextViewText(R.id.notificationTitle, mCourseTitle);
contentView.setProgressBar(R.id.notificationProgressBar, 100, 0, false);
contentView.setTextViewText(R.id.notificationPercentage, "0%");
mNotification.contentView = contentView;
// Create pending intent for the notification
Intent notificationIntent = new Intent(CourseSyncService.this, CancelDownloadActivity.class);
notificationIntent.putExtra(CourseSyncService.KEY_USER_ID, mUserId);
notificationIntent.putExtra(CourseSyncService.KEY_COURSE_ID, mCourseId);
notificationIntent.putExtra(CourseSyncService.KEY_COURSE_TITLE, mCourseTitle);
PendingIntent contentIntent = PendingIntent.getActivity(CourseSyncService.this, mCourseId, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
mNotification.contentIntent = contentIntent;
// Launch notification
mNotificationManager.notify(mCourseId, mNotification);
这里是我如何更新通知:
// Update the progress bar of the notification view
mNotification.contentView.setProgressBar(R.id.notificationProgressBar, mItemCount, mProgressCount, false);
mNotification.contentView.setTextViewText(R.id.notificationPercentage, String.valueOf(mProgress) + "%");
mNotificationManager.notify(mCourseId, mNotification);
通知(ID,通知)有文档指出在同一个ID上通知“将被更新的信息替换”。似乎Honeycomb增加了一个可怕的重新显示,在以前的版本没有发生。 – Rene 2011-08-07 19:19:55
恭喜超过1500!我的投票推动了你的边缘......但主要是感谢问这个问题,我有同样的问题,并修复了这个问题。 – JPM 2012-03-22 22:53:13
呜呼!谢谢! – Chase 2012-03-23 00:07:35