Skip to content

Commit b9b47fc

Browse files
Update manifest, startForeground call
1 parent 59db955 commit b9b47fc

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,14 @@
9696
android:exported="false"
9797
android:label="@string/title_activity_about" />
9898

99-
<service android:name=".local.subscription.services.SubscriptionsImportService" />
100-
<service android:name=".local.subscription.services.SubscriptionsExportService" />
99+
<service
100+
android:name=".local.subscription.services.SubscriptionsImportService"
101+
android:foregroundServiceType="dataSync" />
102+
103+
<service
104+
android:name=".local.subscription.services.SubscriptionsExportService"
105+
android:foregroundServiceType="dataSync" />
106+
101107
<service
102108
android:name=".local.feed.service.FeedLoadService"
103109
android:foregroundServiceType="dataSync" />
@@ -431,6 +437,7 @@
431437
</activity>
432438
<service
433439
android:name=".RouterActivity$FetcherService"
440+
android:foregroundServiceType="dataSync"
434441
android:exported="false" />
435442

436443
<!-- opting out of sending metrics to Google in Android System WebView -->

app/src/main/java/org/schabi/newpipe/player/notification/NotificationUtil.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,8 @@ public void createNotificationAndStartForeground() {
174174
}
175175
updateNotification();
176176

177-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
178-
player.getService().startForeground(NOTIFICATION_ID, notificationBuilder.build(),
179-
ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK);
180-
} else {
181-
player.getService().startForeground(NOTIFICATION_ID, notificationBuilder.build());
182-
}
177+
ServiceCompat.startForeground(player.getService(), NOTIFICATION_ID,
178+
notificationBuilder.build(), ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK);
183179
}
184180

185181
public void cancelNotificationAndStopForeground() {

0 commit comments

Comments
 (0)