I'm trying to use new Notification API setForegroundServiceBehavior. However, when trying to create a build I'm getting an unresolved reference I believe in Android S in general. (I'm working on a different project using Java and there seems to be no problem.)
val builder = Notification.Builder(this, CH_ID)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
builder.setForegroundServiceBehavior(Notification.FOREGROUND_SERVICE_IMMEDIATE);
}
Errors:
Unresolved reference: S
Unresolved reference: setForegroundServiceBehavior
Unresolved reference: FOREGROUND_SERVICE_IMMEDIATE
Gradle:
compileSdkVersion 31
buildToolsVersion "30.0.3"
defaultConfig {
...
minSdkVersion 28
targetSdkVersion 31