我目前有一条通知会显示在我的音乐应用中。它显示控件(上一个,暂停,下一个)
当我单击“暂停”按钮(“ ||”)时,应该更改为播放按钮(“>”)。但是当我单击“暂停”按钮时,它保持不变。
我该如何解决?
这是我的通知
Notification foreground_Notification = new NotificationCompat.Builder(getApplicationContext(), Notification_Channels.Channel_2_ID)
.setSmallIcon(R.drawable.musicicon)
.setContentTitle(songTitle)
.setContentText(artistName)
.setLargeIcon(bitmap)
.setPriority(NotificationManager.IMPORTANCE_NONE)
.addAction(R.drawable.humbup, "Like", likePending)
.addAction(R.drawable.previous3, "Previous", previous)
.addAction(R.drawable.pause3, "Pause", pause_Pending)
.addAction(R.drawable.next3, "Next", next_Pending)
.addAction(R.drawable.cancel, "Cancel", cancel_pending)
.setStyle(new androidx.media.app.NotificationCompat.MediaStyle()
.setShowActionsInCompactView(1, 2, 3)
.setMediaSession(mediaSession.getSessionToken()))
.setContentIntent(pendingIntent)
.build();
startForeground(playingNotificationId, foreground_Notification);
这是我的暂停/播放按钮的待定意图:
Intent Pause = new Intent("PAUSE");
PendingIntent pause_Pending = PendingIntent.getBroadcast(getApplicationContext(), 100, Pause, 0);
这是我的暂停/播放待定意图广播接收器
if (intent.getActions.equalsIgnoreCase("PAUSE")) {
if (isPlaying()) {
pause();
} else {
play();
}