Android 通知栏点击不起作用
我有以下代码在 C2DMReceiver.java 的通知栏中发出通知。这个类本身扩展了BroadcastReceiver。以下代码位于 onReceive 方法中。
NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
int icon = R.drawable.ic_call;
CharSequence text = "Match Found";
CharSequence contentTitle = "Match";
CharSequence contentText = received.getExtras().getString("matches");
long when = System.currentTimeMillis();
Intent intent = new Intent(context, C2DMReceiver.class);
PendingIntent contentIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
Notification notification = new Notification(icon,text,when);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
notificationManager.notify(34, notification);
现在,当我单击通知栏中的通知时。 c2DmReceiver 类的 onReceive 方法未调用。
请帮忙...
I have following code to make notification in notification bar in C2DMReceiver.java. This class itself extends BroadcastReceiver. and following code is in onReceive method.
NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
int icon = R.drawable.ic_call;
CharSequence text = "Match Found";
CharSequence contentTitle = "Match";
CharSequence contentText = received.getExtras().getString("matches");
long when = System.currentTimeMillis();
Intent intent = new Intent(context, C2DMReceiver.class);
PendingIntent contentIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
Notification notification = new Notification(icon,text,when);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
notificationManager.notify(34, notification);
Now when I am clicking on notification in notification bar. onReceive method of c2DmReceiver class is not invoking.
Please help...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否在 Manifest 文件中注册了 C2DMReceiver?如果您已经注册,请尝试将以下行更改为Manifest文件中相应的IntentFilter并检查。
Did you registered C2DMReceiver in your Manifest file? If you have registered, try changing the below line to the corresponding IntentFilter in Manifest file and check.