Advertisement
retnet

androidX mediastyle

Mar 1st, 2020
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.52 KB | None | 0 0
  1. builder.setStyle(new androidx.media.app.NotificationCompat.MediaStyle());
  2.  
  3. NotificationCompat.Builder builder = new NotificationCompat.Builder(service, PRIMARY_CHANNEL)
  4.                 .setAutoCancel(false)
  5.                 .setContentTitle(strAppName)
  6.                 .setContentText(strLiveBroadcast)
  7.                 .setLargeIcon(largeIcon)
  8.                 .setContentIntent(pendingIntent)
  9.                 .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
  10.                 .setSmallIcon(R.drawable.ic_launcher)
  11.                 .addAction(icon, "pause", action)
  12.                 .addAction(R.drawable.exo_notification_stop, "stop", stopAction)
  13.                 .setPriority(NotificationCompat.PRIORITY_HIGH)
  14.                 .setWhen(System.currentTimeMillis())
  15. //                .setStyle(new android.support.v4.media.app.NotificationCompat.MediaStyle() // lawas
  16.                 .setStyle(new androidx.media.app.NotificationCompat.MediaStyle()
  17.                         .setMediaSession(service.getMediaSession().getSessionToken())
  18.                         .setShowActionsInCompactView(0, 1)
  19.                         .setShowCancelButton(true)
  20.                         .setCancelButtonIntent(stopAction));
  21.         service.startForeground(NOTIFICATION_ID, builder.build());
  22. ////////////////////
  23. ////##############
  24.         <receiver android:name="androidx.media.session.MediaButtonReceiver">
  25.             <intent-filter>
  26.                 <action android:name="android.intent.action.MEDIA_BUTTON"/>
  27.             </intent-filter>
  28.         </receiver>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement