Skip to content

Commit

Permalink
Set notification style in Android 11 to MediaStyle
Browse files Browse the repository at this point in the history
Google messed up old notifications.
  • Loading branch information
XiangRongLin committed Dec 7, 2020
1 parent 4bca8f4 commit aa55a09
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.util.Log;
Expand All @@ -40,6 +42,8 @@
import androidx.annotation.RequiresApi;
import androidx.core.app.NotificationCompat;

import androidx.core.app.NotificationCompat.DecoratedCustomViewStyle;
import androidx.media.app.NotificationCompat.MediaStyle;
import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.source.MediaSource;
Expand Down Expand Up @@ -224,6 +228,11 @@ private NotificationCompat.Builder createNotification() {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
builder.setPriority(NotificationCompat.PRIORITY_MAX);
}

if (VERSION.SDK_INT > VERSION_CODES.Q) {
builder.setStyle(new MediaStyle());
}

return builder;
}

Expand Down

0 comments on commit aa55a09

Please sign in to comment.