2016-03-19 11 views
0

Ich habe 2 Probleme mit meinem NotificationCompat.Builder als Mediastyle eingerichtet:Android Mediastyle NotificationCompat zeigt 3 Aktionen maximale

1) Ich habe bis 5 Aktionen und nur 3 in der erweiterten Meldung angezeigt. (Die ersten 3 angezeigten Aktionen funktionieren einwandfrei).

2) Keine Aktion wird in der kompakten Benachrichtigung angezeigt, obwohl ich eine Aktion eingerichtet habe.

Ich teste auf einem Samsung S4 auf Lollipop 5.1.1 (Cyanogen) und meine App nutzt Support-Bibliothek 23.2.1

Unten ist mein NotificationCompat.Builder:

 notificationBuilder = new NotificationCompat.Builder(act) 
      .setPriority(NotificationCompat.PRIORITY_HIGH) 
      .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) 
      .setCategory(NotificationCompat.CATEGORY_TRANSPORT) 
      .setContentTitle(podcastName) 
      .setContentText(episodeName) 
      .setOngoing(true) 
      .setShowWhen(true) 
      .setContentIntent(activityMainPI) 
      .setSmallIcon(smallIcon) 
      .setLargeIcon(largeIcon) 
      .setAutoCancel(false) 
      .addAction(previousAction) 
      .addAction(playAction) 
      .addAction(nextAction) 
      .addAction(rewindAction) 
      .addAction(forwardAction) 
      .setStyle(new MediaStyle() 
          .setShowActionsInCompactView(new int[]{1}) 
      ); 
+0

Alle Aktionen bitte posten. –

Antwort

2

Ich habe den Grund für dieses Problem gefunden. Ich benutzte die Support-Bibliothek v4 appcompat statt der v7

So ersetzt:

import android.support.v4.app.NotificationCompat; 

von:

import android.support.v7.app.NotificationCompat; 

das Problem behoben.

Dies war auch der Grund für eine andere meiner issues mit der Media Style Notification.

0

Eugen, bitte Finden Sie die erste Aktion (die anderen sind ähnlich):

previousPI = PendingIntent.getBroadcast(context, 100, new Intent(TOOLS_CONST.ACTION_PREVIOUS), 0); 

    previousAction = new NotificationCompat.Action.Builder(R.drawable.ic_action_previous_light, null, previousPI).build();