Use requireActivity() instead of requireContext() - only the first is guaranteed to return an activity