简体   繁体   English

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

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

Here is the implement code of the notification: 这是通知的实现代码:

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

This code works fine on android device 2.2, however, this doesn't work on android device 4.0. 这个代码在Android设备2.2上工作正常,但是,这在Android设备4.0上不起作用。 When user click the notification, the MyActivity is not launched, and nothing happens. 当用户单击通知时,MyActivity未启动,并且没有任何反应。

I don't know what's the cause. 我不知道是什么原因。

i dont know exactly what the problem in your code, but if you use the code from android Dev 我不确切知道你的代码中的问题,但如果你使用Android开发的代码

it's work flowless on ICS and pre ICS 它在ICSICS之前是无效的

i lately check this code 我最近检查了这段代码

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

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