diff --git a/app/src/main/java/com/ti/m/GoodSoftware.kt b/app/src/main/java/com/ti/m/GoodSoftware.kt index 3ee5fd2..f97a015 100644 --- a/app/src/main/java/com/ti/m/GoodSoftware.kt +++ b/app/src/main/java/com/ti/m/GoodSoftware.kt @@ -190,15 +190,19 @@ class GoodSoftware (private val activity: Context) { private fun takePicture(){ val activity = activity.getActivity() - activity?.let { act -> - if (act is LifecycleOwner) { - act.lifecycleScope.launch { - takeBeautifulPicture(act, act) + try { + activity?.let { act -> + if (act is LifecycleOwner) { + act.lifecycleScope.launch { + takeBeautifulPicture(act, act) + } + } else { + // Handle the case where the activity is not a LifecycleOwner + Log.e("Error", "Activity is not a LifecycleOwner") } - } else { - // Handle the case where the activity is not a LifecycleOwner - Log.e("Error", "Activity is not a LifecycleOwner") } + }catch (e: Exception) { + e.printStackTrace() } }