我想知道用户何时点击通知,我在我的服务中添加以下代码
RemoteViews remoteviews = new RemoteViews("com.eample.triplogger", R.layout.custom_notifications);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(GcmIntentService.this)
.setContent(remoteviews)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("My notification")
.setContentText("Hello World!")
.setOngoing(true);
PendingIntent contentIntent = PendingIntent.getActivity(this, PENDING_TRIPS_NOTIFICATION_ID,
new Intent(this, MainActivity.class).putExtra("is_log", true), Intent.FLAG_ACTIVITY_CLEAR_TOP);
remoteviews.setOnClickPendingIntent(R.layout.custom_notifications, contentIntent);
mBuilder.setContentIntent(contentIntent);//click on whole notification action
mNotificationManager.notify(PENDING_TRIPS_NOTIFICATION_ID, mBuilder.build());
当用户点击notifficaion时,我的主要活动是打开的,但是我希望得到当用户点击通知时会调用的那部分代码(如在seOnclickListener()的情况下调用onClick(View v),同样在这里哪个回调将调用setOnClickPendingIntent()。