我的通知中有一个暂停按钮,单击它应该转到广播接收器。以下是我的代码:
NotificationCompat.Builder builder = new NotificationCompat.Builder(WalkTrackingActivity.this);
remoteViews = new RemoteViews(getPackageName(), R.layout.content_user_manual);
remoteViews.setChronometer(R.id.chronometer, SystemClock.elapsedRealtime(), null, false);
Intent intent = new Intent(WalkTrackingActivity.this, WalkTrackingActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(WalkTrackingActivity.this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
Intent fillInIntent = new Intent(this, pauseButtonListener.class);
fillInIntent.setPackage(getPackageName());
fillInIntent.setAction("PAUSE");
PendingIntent templateIntent = PendingIntent.getBroadcast(this, 0, fillInIntent, PendingIntent.FLAG_UPDATE_CURRENT);
remoteViews.setPendingIntentTemplate(R.layout.content_user_manual, templateIntent);
RemoteViews btnView=new RemoteViews (getPackageName(),R.id.imageButton5);
btnView.setOnClickFillInIntent(R.id.imageButton5, fillInIntent);
notification = builder
.setSmallIcon(getNotificationIcon())
.setContentIntent(pendingIntent)
.setAutoCancel(true)
.setOnlyAlertOnce(true)
.setContent(remoteViews)
.build();
notification.flags = Notification.FLAG_ONGOING_EVENT;
notificationManager = (NotificationManager)
WalkTrackingActivity.this.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notification);
我已经在清单中注册了我的监听器。仍然无法正常工作。请帮忙!