0

我想知道用户何时点击通知,我在我的服务中添加了以下代码

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

wo当用户点击notifficaion时,我的主要活动是打开的,但我想获得当用户点击通知时将调用的那部分代码(如在seOnclickListener()的情况下调用onClick(View v),这里与回调相同将调用 setOnClickPendingIntent()。

4

0 回答 0