diff options
Diffstat (limited to 'app/src/main/java/app/fedilab/android/mastodon/jobs/ScheduleThreadWorker.java')
-rw-r--r-- | app/src/main/java/app/fedilab/android/mastodon/jobs/ScheduleThreadWorker.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/app/src/main/java/app/fedilab/android/mastodon/jobs/ScheduleThreadWorker.java b/app/src/main/java/app/fedilab/android/mastodon/jobs/ScheduleThreadWorker.java index b5f4dcc89..4a48a8d27 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/jobs/ScheduleThreadWorker.java +++ b/app/src/main/java/app/fedilab/android/mastodon/jobs/ScheduleThreadWorker.java @@ -20,6 +20,7 @@ import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; import android.content.Context; +import android.content.pm.ServiceInfo; import android.graphics.BitmapFactory; import android.os.Build; @@ -66,7 +67,12 @@ public class ScheduleThreadWorker extends Worker { .setContentText(getApplicationContext().getString(R.string.scheduled_toots)) .setDefaults(NotificationCompat.DEFAULT_ALL) .setPriority(Notification.PRIORITY_DEFAULT); - return Futures.immediateFuture(new ForegroundInfo(NOTIFICATION_INT_CHANNEL_ID, notificationBuilder.build())); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + return Futures.immediateFuture(new ForegroundInfo(NOTIFICATION_INT_CHANNEL_ID, notificationBuilder.build(), ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC)); + } else { + return Futures.immediateFuture(new ForegroundInfo(NOTIFICATION_INT_CHANNEL_ID, notificationBuilder.build())); + } } @NonNull @@ -86,7 +92,12 @@ public class ScheduleThreadWorker extends Worker { .setContentText(getApplicationContext().getString(R.string.scheduled_toots)) .setDefaults(NotificationCompat.DEFAULT_ALL) .setPriority(Notification.PRIORITY_DEFAULT); - return new ForegroundInfo(NOTIFICATION_INT_CHANNEL_ID, notificationBuilder.build()); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + return new ForegroundInfo(NOTIFICATION_INT_CHANNEL_ID, notificationBuilder.build(), ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC); + } else { + return new ForegroundInfo(NOTIFICATION_INT_CHANNEL_ID, notificationBuilder.build()); + } } @NonNull |