以下是通知的实施代码:
Notification notification = new Notification();
RemoteViews expandedView = new RemoteViews(mContext.getPackageName(),
R.layout.status_bar_ongoing_event_progress_bar);
// ignore the setup code for expanedView
notification.contentView = expandedView;
Intent intent = new Intent(mContext, MyActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(mContext, 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
notification.contentIntent = contentIntent;
mNotificationMgr.notify(notification_id, notification);
此代码在Android设备2.2上运行良好,但是,这在Android设备4.0上不起作用。当用户单击通知时,MyActivity不会启动,也不会发生任何事情。
我不知道是什么原因。