Notifications I';我试图发出通知来打开和关闭音乐播放器,但它没有';行不通

Notifications I';我试图发出通知来打开和关闭音乐播放器,但它没有';行不通,notifications,Notifications,notificationManager=(notificationManager)getSystemService(通知服务); if(Build.VERSION.SDK\u INT>=Build.VERSION\u code.O){ NotificationChannel NotificationChannel=新的NotificationChannel(通知通道ID, “我的通知”,通知经理。重要性较低); notificationManager.createNotificationChan

notificationManager=(notificationManager)getSystemService(通知服务); if(Build.VERSION.SDK\u INT>=Build.VERSION\u code.O){ NotificationChannel NotificationChannel=新的NotificationChannel(通知通道ID, “我的通知”,通知经理。重要性较低); notificationManager.createNotificationChannel(notificationChannel)

    notificationManager.createNotificationChannel(notificationChannel);
    notificationChannel.enableVibration(false);
    notificationChannel.setSound(null, null);
}
RemoteViews collapsedView = new RemoteViews(getPackageName(),
        R.layout.notification_collapsed);
PendingIntent contentIntent = PendingIntent.getActivity(this,
        0, new Intent(this, ListSearch.class), 0);

NotificationCompat.Builder builder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID)
        .setSmallIcon(R.mipmap.ic_launcher)
        .setCustomContentView(collapsedView)
        .setContentIntent ( contentIntent );

listener(collapsedView,sound_index,getApplicationContext());

        notificationManager.notify(NOTIFICATION_ID, builder.build());

}
public void listener(final RemoteViews remoteViews, int index, Context context) {
    Intent intent = new Intent("Play");
    Intent intent2 = new Intent("Next");
    Intent intent3 = new Intent("Pre");

    PendingIntent pendingPlay = PendingIntent.getBroadcast(context,1,intent,0);
    final PendingIntent pendingNext = PendingIntent.getBroadcast(context,1,intent2,0);
    final PendingIntent pendingPre = PendingIntent.getBroadcast(context,1,intent3,0);

    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction("Play");
    intentFilter.addAction("Next");
    intentFilter.addAction("Pre");



    remoteViews.setOnClickPendingIntent(R.id.button,pendingPlay);
    remoteViews.setOnClickPendingIntent(R.id.button1,pendingNext);
    remoteViews.setOnClickPendingIntent(R.id.play_pause,pendingPre);
    remoteViews.setTextViewText(R.id.textView1, listitems.get ( index ).getTitle ( ));

    BroadcastReceiver receiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction().equals("Play")) {

                if(sound.isPlaying()) {
                    sound.stop();
                }else {
                    sound.start();

                }




            } else if(intent.getAction().equals("Next")) {
                playNextSong();

            } else if(intent.getAction().equals("Pre")) {
                playPreviousSong();




            }
        }
    };

    context.registerReceiver(receiver,intentFilter);


}