我现在想在通知栏里,显示下载进度,但是调用:
mNotificationManager.notify(CUSTOM_VIEW_ID, notification1);
抛出如下异常:5-08 14:45:20.731: E/AndroidRuntime(12364): android.app.RemoteServiceException: Bad notification posted from package com.android.launcher3d: Couldn't expand RemoteViews for: StatusBarNotification(package=com.android.launcher3d id=1001 tag=null notification=Notification(vibrate=default,sound=default,defaults=0x3,flags=0x2))
mNotificationManager.notify(CUSTOM_VIEW_ID, notification1);
抛出如下异常:5-08 14:45:20.731: E/AndroidRuntime(12364): android.app.RemoteServiceException: Bad notification posted from package com.android.launcher3d: Couldn't expand RemoteViews for: StatusBarNotification(package=com.android.launcher3d id=1001 tag=null notification=Notification(vibrate=default,sound=default,defaults=0x3,flags=0x2))
public void showDownloadDialog() {
String tickerText1 = "Custom view for download notification";
int icon1 = android.R.drawable.stat_sys_download;
mNotificationManager = (NotificationManager) mContext
.getSystemService(Context.NOTIFICATION_SERVICE); Intent notificationIntent1 = new Intent(mContext, mContext.getClass());
notificationIntent1.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent contentIntent1 = PendingIntent.getActivity(mContext, 0,
notificationIntent1, 0); notification1 = new Notification(icon1, tickerText1,
System.currentTimeMillis()); notification1.defaults |= Notification.DEFAULT_SOUND; notification1.defaults |= Notification.DEFAULT_VIBRATE; notification1.flags |= Notification.FLAG_ONGOING_EVENT; RemoteViews contentView = new RemoteViews(mContext.getPackageName(),
R.layout.update_download_notification);
contentView.setTextViewText(R.id.notificationTitle,
"Download:launcher3D");
contentView.setTextViewText(R.id.notificationPercent, "0%");
contentView.setProgressBar(R.id.notificationProgress, 100, 0, false); notification1.contentView = contentView;
notification1.contentIntent = contentIntent1; mNotificationManager.notify(CUSTOM_VIEW_ID, notification1);
notification1.contentView.setProgressBar(CUSTOM_VIEW_ID, 100, 0, false);
downloadApk();
}
//handler里:
case DOWN_UPDATE:
notification1.contentView.setTextViewText(
R.id.notificationPercent, progress + "%");
notification1.contentView.setProgressBar(CUSTOM_VIEW_ID, 100,
progress, false);
mNotificationManager.notify(CUSTOM_VIEW_ID, notification1);//此处抛异常
break;
http://topic.csdn.net/u/20110526/11/187770aa-261b-4512-b612-23a84ae44041.html