From eb571031bac5b4e61d98b88c5c56592a8e320c3a Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Fri, 19 Jan 2024 17:01:43 +0530 Subject: [PATCH] Fixed crashes occurring in Version 3.8.1 when opening ZIM files. * A user provided logs indicating that, during the attempt to open ZIM files, a crash occurred when stopping the TTS service. The logs revealed that, in the absence of any activity to stop the service, using `requireActivity()` resulted in an error and application crash. To address this issue, we replaced `requireActivity()` with `activity`. Now, if there is no activity present, using `activity` avoids the error that would lead to a crash. --- .../java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt index 4c4046122..37e02cea1 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt @@ -2236,7 +2236,7 @@ abstract class CoreReaderFragment : } private fun setActionAndStartTTSService(action: String, isPauseTTS: Boolean = false) { - requireActivity().startService( + activity?.startService( createReadAloudIntent(action, isPauseTTS) ).also { isReadAloudServiceRunning = action == ACTION_PAUSE_OR_RESUME_TTS