title: Music player control in notification
body: <p>how to set notification with play/pause, next and previous button in android.!</p>
  
  <p>I am new with Android &amp; also at stack overflow. So please bear with me.</p>
  
  <p><img src="https://i.stack.imgur.com/2YEGI.png" alt="enter image description here"></p>
  
  <p>I set notification when song is start to play like below : </p>
  
  <p>`</p>
  
  <pre><code>@SuppressLint("NewApi")
  public void setNotification(String songName){
      String ns = Context.NOTIFICATION_SERVICE;
      NotificationManager notificationManager = (NotificationManager) getSystemService(ns);
  
  
      @SuppressWarnings("deprecation")
      Notification notification = new Notification(R.drawable.god_img, null, System.currentTimeMillis());
  
      RemoteViews notificationView = new RemoteViews(getPackageName(), R.layout.notification_mediacontroller);
  
      //the intent that is started when the notification is clicked (works)
      Intent notificationIntent = new Intent(this, AudioBookListActivity.class);
      PendingIntent pendingNotificationIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
  
      notification.contentView = notificationView;
      notification.contentIntent = pendingNotificationIntent;
      notification.flags |= Notification.FLAG_NO_CLEAR;
  
      //this is the intent that is supposed to be called when the button is clicked
      Intent switchIntent = new Intent(this, AudioPlayerBroadcastReceiver.class);
      PendingIntent pendingSwitchIntent = PendingIntent.getBroadcast(this, 0, switchIntent, 0);
  
      notificationView.setOnClickPendingIntent(R.id.btn_play_pause_in_notification, pendingSwitchIntent);
      notificationManager.notify(1, notification);        
  }
  </code></pre>
  
  <p>`</p>
  
  <p>I have create BroadcastReceiver like below :
   `      </p>
  
  <pre><code>   private class AudioPlayerBroadcastReceiver extends BroadcastReceiver {
      @Override
      public void onReceive(Context context, Intent intent) {
          String action = intent.getAction();
          System.out.println("intent action = " + action);
          long id = intent.getLongExtra("id", -1);
  
          if(Constant.PLAY_ALBUM.equals(action)) {
              //playAlbum(id);
          } else if(Constant.QUEUE_ALBUM.equals(action)) {
              //queueAlbum(id);
          } else if(Constant.PLAY_TRACK.equals(action)) {
              //playTrack(id);
          } else if(Constant.QUEUE_TRACK.equals(action)) {
              //queueTrack(id);
          } else if(Constant.PLAY_PAUSE_TRACK.equals(action)) {
   //                playPauseTrack();
              System.out.println("press play");
          } else if(Constant.HIDE_PLAYER.equals(action)) {
   //                hideNotification();
              System.out.println("press next");
          }
          else {
          }
      }
  
  }`
  </code></pre>
  
  <p>Now, I set custom notification successfully but how can i handle notification buttons and its events like play/pause, previous and next... etc. I also try using broadcast receiver but could not get any response. </p>
  
  <p>Seeking solution and guidance from experts, please help me out.</p>
  
  <p>Thanks in advance.</p>