From be58f2b2e6fe02f2d4344b2b39a0163653ec53f0 Mon Sep 17 00:00:00 2001 From: Rif009 <49874444+Rif009@users.noreply.github.com> Date: Mon, 24 Jun 2024 23:06:12 +0300 Subject: [PATCH] Update StrideActivity.cs fix android 14 --- .../Stride.Games/Starter/StrideActivity.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/sources/engine/Stride.Games/Starter/StrideActivity.cs b/sources/engine/Stride.Games/Starter/StrideActivity.cs index 0e0cb383b0..f8ee6d0b2b 100644 --- a/sources/engine/Stride.Games/Starter/StrideActivity.cs +++ b/sources/engine/Stride.Games/Starter/StrideActivity.cs @@ -40,7 +40,15 @@ protected override void OnRun() { // set up a listener to the android ringer mode (Normal/Silent/Vibrate) ringerModeIntentReceiver = new RingerModeIntentReceiver((AudioManager)GetSystemService(AudioService)); - RegisterReceiver(ringerModeIntentReceiver, new IntentFilter(AudioManager.RingerModeChangedAction)); + if (OperatingSystem.IsAndroidVersionAtLeast(34)) + { + RegisterReceiver(ringerModeIntentReceiver, new IntentFilter(AudioManager.RingerModeChangedAction), ReceiverFlags.Exported); + } + else + { + RegisterReceiver(ringerModeIntentReceiver, new IntentFilter(AudioManager.RingerModeChangedAction)); + } + // Set the android global context if (PlatformAndroid.Context == null) @@ -70,7 +78,14 @@ protected override void OnResume() { base.OnResume(); - RegisterReceiver(ringerModeIntentReceiver, new IntentFilter(AudioManager.RingerModeChangedAction)); + if (OperatingSystem.IsAndroidVersionAtLeast(34)) + { + RegisterReceiver(ringerModeIntentReceiver, new IntentFilter(AudioManager.RingerModeChangedAction), ReceiverFlags.Exported); + } + else + { + RegisterReceiver(ringerModeIntentReceiver, new IntentFilter(AudioManager.RingerModeChangedAction)); + } } ///