Umgang mit Klicks auf Benachrichtigungstaste und die Benachrichtigung Teil selbst in android
ich eine Benachrichtigung haben, die „Jetzt: Radio“ sagt und es hat eine Stopp-Taste darunter. Wenn der Benutzer auf die Stopp-Schaltfläche klickt, hört der Ton auf und ich versuche nun, wenn der Benutzer auf den Benachrichtigungsteil oberhalb der Stopp-Schaltfläche klickt, möchte ich ein Fragment öffnen. Ich zeige die Benachrichtigung so.
Intent notIntent = new Intent();
notIntent.setAction(ACTION_STOP);
PendingIntent pendInt = PendingIntent.getService(this, (int) System.currentTimeMillis(),
notIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Notification n = builder.setContentIntent(pendInt)
.setSmallIcon(R.drawable.music_nepal_not)
.setColor(ContextCompat.getColor(BackgroundAudioService.this, R.color.colorPrimary))
.setTicker("Playing Live Radio")
.setContentTitle("Now Playing : Live Radio ")
.addAction(R.layout.toggle_notification, "", pendInt)
.build();
notificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
n.flags |= Notification.FLAG_NO_CLEAR;
notificationManager.notify(0, n);