From ec27d20ac8fd2ac30680028d776243411267a7b2 Mon Sep 17 00:00:00 2001 From: jrfeng Date: Wed, 18 Oct 2023 22:03:18 +0800 Subject: [PATCH] fix bug: PlayerService crash on target API 34 #53 --- player/build.gradle | 4 ++-- player/src/main/java/snow/player/PlayerService.java | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/player/build.gradle b/player/build.gradle index 9dcf429a..c5aab959 100644 --- a/player/build.gradle +++ b/player/build.gradle @@ -2,11 +2,11 @@ apply plugin: 'com.android.library' apply plugin: 'maven-publish' android { - compileSdkVersion 33 + compileSdkVersion 34 defaultConfig { minSdkVersion 16 - targetSdkVersion 33 + targetSdkVersion 34 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles 'consumer-rules.pro' diff --git a/player/src/main/java/snow/player/PlayerService.java b/player/src/main/java/snow/player/PlayerService.java index ca105de7..9a54ee60 100644 --- a/player/src/main/java/snow/player/PlayerService.java +++ b/player/src/main/java/snow/player/PlayerService.java @@ -555,7 +555,12 @@ public void onReceive(Context context, Intent intent) { }; IntentFilter filter = new IntentFilter(this.getClass().getName()); - registerReceiver(mCustomActionReceiver, filter); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { + registerReceiver(mCustomActionReceiver, filter, Context.RECEIVER_NOT_EXPORTED); + } else { + registerReceiver(mCustomActionReceiver, filter); + } } private void initSyncPlayerStateHandler() {