File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed
app/src/main/java/org/schabi/newpipe Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package org.schabi.newpipe.local.feed.notifications
22
33import android.content.Context
44import android.content.pm.ServiceInfo
5+ import android.os.Build
56import android.util.Log
67import androidx.core.app.NotificationCompat
78import androidx.work.Constraints
@@ -84,8 +85,7 @@ class NotificationWorker(
8485 .setPriority(NotificationCompat .PRIORITY_LOW )
8586 .setContentTitle(applicationContext.getString(R .string.feed_notification_loading))
8687 .build()
87- @Suppress(" NewApi" ) // ServiceInfo constant is inlined
88- val serviceType = ServiceInfo .FOREGROUND_SERVICE_TYPE_DATA_SYNC
88+ val serviceType = if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .Q ) ServiceInfo .FOREGROUND_SERVICE_TYPE_DATA_SYNC else 0
8989 setForegroundAsync(ForegroundInfo (FeedLoadService .NOTIFICATION_ID , notification, serviceType))
9090 }
9191
Original file line number Diff line number Diff line change @@ -167,15 +167,16 @@ public boolean shouldUpdateBufferingSlot() {
167167 && notificationBuilder .mActions .get (2 ).actionIntent != null );
168168 }
169169
170- @ SuppressLint ("NewApi" ) // ServiceInfo constant is inlined
171170 public void createNotificationAndStartForeground () {
172171 if (notificationBuilder == null ) {
173172 notificationBuilder = createNotification ();
174173 }
175174 updateNotification ();
176175
176+ final int serviceType = Build .VERSION .SDK_INT >= Build .VERSION_CODES .Q
177+ ? ServiceInfo .FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK : 0 ;
177178 ServiceCompat .startForeground (player .getService (), NOTIFICATION_ID ,
178- notificationBuilder .build (), ServiceInfo . FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK );
179+ notificationBuilder .build (), serviceType );
179180 }
180181
181182 public void cancelNotificationAndStopForeground () {
You can’t perform that action at this time.
0 commit comments