I have a pause button in my notification, on click of which should go to the broadcast receiver. The following is my code:
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);
I have registered my listner in manifest. Still it is not working. Please help!