繁体   English   中英

在Android 4.0版上单击通知时,永远不会启动Activity

[英]Activity is never launched when the notification is clicked on android version 4.0

这是通知的实现代码:

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未启动,并且没有任何反应。

我不知道是什么原因。

我不确切知道你的代码中的问题,但如果你使用Android开发的代码

它在ICSICS之前是无效的

我最近检查了这段代码

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM