diff --git a/android/build.gradle b/android/build.gradle index 33a3357..fe49340 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -22,7 +22,7 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdkVersion 33 + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 @@ -39,6 +39,7 @@ android { defaultConfig { minSdkVersion 16 + compileSdk 34 } } diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 90067b2..1fc53e2 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -3,7 +3,8 @@ + - + diff --git a/android/src/main/kotlin/qiuxiang/android_window/WindowService.kt b/android/src/main/kotlin/qiuxiang/android_window/WindowService.kt index 5042588..1a87a39 100644 --- a/android/src/main/kotlin/qiuxiang/android_window/WindowService.kt +++ b/android/src/main/kotlin/qiuxiang/android_window/WindowService.kt @@ -4,6 +4,7 @@ import android.app.Notification import android.app.NotificationChannel import android.app.NotificationManager import android.content.Intent +import android.content.pm.ServiceInfo import android.content.res.Configuration import android.os.Build import android.os.IBinder @@ -47,7 +48,12 @@ class WindowService : android.app.Service() { val y = intent.getIntExtra("y", 0) androidWindow = AndroidWindow(this, focusable, width, height, x, y, engine) androidWindow.open() - startForeground(1, getNotification()) + val notification = getNotification() + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) { + startForeground(1, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE) + } else { + startForeground(1, notification) + } running = true } return super.onStartCommand(intent, flags, startId)