File tree Expand file tree Collapse file tree
kotlin/com/github/gotify/service Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010 <uses-permission android : name =" android.permission.ACCESS_NETWORK_STATE" />
1111 <uses-permission android : name =" android.permission.POST_NOTIFICATIONS" />
1212 <uses-permission android : name =" android.permission.SCHEDULE_EXACT_ALARM" />
13+ <uses-permission android : name =" android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
1314
1415 <application
1516 android : name =" .GotifyApplication"
7374 android : exported =" false"
7475 android : theme =" @style/AppTheme.Dialog" />
7576
76- <service android : name =" .service.WebSocketService" />
77+ <service
78+ android : name =" .service.WebSocketService"
79+ android : foregroundServiceType =" specialUse" >
80+ <property
81+ android : name =" android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
82+ android : value =" explanation_for_special_use" />
83+ </service >
7784
7885 <receiver android : name =" .init.BootCompletedReceiver"
7986 android : exported =" true" >
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import android.app.NotificationManager
66import android.app.PendingIntent
77import android.app.Service
88import android.content.Intent
9+ import android.content.pm.ServiceInfo
910import android.graphics.Color
1011import android.net.ConnectivityManager
1112import android.net.Network
@@ -285,7 +286,15 @@ internal class WebSocketService : Service() {
285286
286287 notificationBuilder.setContentIntent(pendingIntent)
287288 notificationBuilder.color = ContextCompat .getColor(applicationContext, R .color.colorPrimary)
288- startForeground(NotificationSupport .ID .FOREGROUND , notificationBuilder.build())
289+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .UPSIDE_DOWN_CAKE ) {
290+ startForeground(
291+ NotificationSupport .ID .FOREGROUND ,
292+ notificationBuilder.build(),
293+ ServiceInfo .FOREGROUND_SERVICE_TYPE_SPECIAL_USE
294+ )
295+ } else {
296+ startForeground(NotificationSupport .ID .FOREGROUND , notificationBuilder.build())
297+ }
289298 }
290299
291300 private fun showNotification (
You can’t perform that action at this time.
0 commit comments