From c10ffda91feb3476a861c47fb38641c1007b9d33 Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Wed, 12 Jul 2023 21:54:21 -0400 Subject: [PATCH] android: Restore notification permission request (#6693) When we targeted API <32, the notification permission would automatically be requested on startup. This restores that behavior temporarily while we work on new UX. --- src/android/app/src/main/AndroidManifest.xml | 1 + .../org/citra/citra_emu/ui/main/MainActivity.java | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/android/app/src/main/AndroidManifest.xml b/src/android/app/src/main/AndroidManifest.xml index 3df8d45d6..4639b0d5f 100644 --- a/src/android/app/src/main/AndroidManifest.xml +++ b/src/android/app/src/main/AndroidManifest.xml @@ -29,6 +29,7 @@ + requestNotificationPermissionLauncher = + registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> { }); + @Override protected void onCreate(Bundle savedInstanceState) { SplashScreen splashScreen = SplashScreen.installSplashScreen(this); @@ -165,6 +172,12 @@ public final class MainActivity extends AppCompatActivity implements MainView { EmulationActivity.tryDismissRunningNotification(this); setInsets(); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) { + requestNotificationPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS); + } + } } @Override