From 68b920b9ee2e7983e450d4eb28a2e95dd6f9b860 Mon Sep 17 00:00:00 2001 From: Volodymyr Date: Tue, 13 Feb 2024 19:51:28 +0200 Subject: [PATCH] Bump Gradle in example app, pass service type --- .../notification/NotificationService.kt | 9 +++++++-- example/android/app/build.gradle | 12 ++++++++---- example/android/build.gradle | 4 ++-- .../android/gradle/wrapper/gradle-wrapper.properties | 2 +- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/android/src/main/kotlin/com/github/florent37/assets_audio_player/notification/NotificationService.kt b/android/src/main/kotlin/com/github/florent37/assets_audio_player/notification/NotificationService.kt index 3d67d196..22719213 100644 --- a/android/src/main/kotlin/com/github/florent37/assets_audio_player/notification/NotificationService.kt +++ b/android/src/main/kotlin/com/github/florent37/assets_audio_player/notification/NotificationService.kt @@ -13,7 +13,6 @@ import android.os.Build import android.os.IBinder import android.support.v4.media.MediaMetadataCompat import android.support.v4.media.session.PlaybackStateCompat -import android.support.v4.media.session.PlaybackStateCompat.ACTION_SEEK_TO import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat import androidx.media.session.MediaButtonReceiver @@ -24,6 +23,7 @@ import kotlinx.coroutines.launch import kotlin.math.abs import android.app.PendingIntent.FLAG_UPDATE_CURRENT import android.app.PendingIntent.FLAG_IMMUTABLE +import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK import android.support.v4.media.session.MediaSessionCompat import androidx.annotation.RequiresApi import com.github.florent37.assets_audio_player.AssetsAudioPlayerPlugin @@ -346,7 +346,12 @@ class NotificationService : Service() { } .setShowWhen(false) .build() - startForeground(NOTIFICATION_ID, notification) + + if (Build.VERSION.SDK_INT >= 29) { + startForeground(NOTIFICATION_ID, notification, FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK) + } else { + startForeground(NOTIFICATION_ID, notification) + } //fix for https://github.com/florent37/Flutter-AssetsAudioPlayer/issues/139 if (!action.isPlaying && Build.VERSION.SDK_INT >= 24) { diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 6f7805ee..624d4815 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -26,7 +26,11 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 33 + if (project.android.hasProperty("namespace")) { + namespace 'com.github.florent37.example' + } + + compileSdk 34 sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -39,8 +43,8 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.github.florent37.example" - minSdkVersion 19 - targetSdkVersion 33 + minSdk 19 + targetSdk 34 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } @@ -63,5 +67,5 @@ flutter { } dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } diff --git a/example/android/build.gradle b/example/android/build.gradle index 11c7f341..954fa1cd 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,12 +1,12 @@ buildscript { - ext.kotlin_version = '1.6.10' + ext.kotlin_version = '1.7.21' repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.0.2' + classpath 'com.android.tools.build:gradle:7.4.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 595fb867..e6b38c2d 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip