I will keep updating this with time.

Check if Intent is resolvable

// Creating our Share Intent
private fun getShareIntent() : Intent {
   val args = GameWonFragmentArgs.fromBundle(requireArguments())
   val shareIntent = Intent(Intent.ACTION_SEND)
   shareIntent.setType("text/plain")
            .putExtra(Intent.EXTRA_TEXT, getString(R.string.share_success_text, args.numCorrect, args.numQuestions))
   return shareIntent
}
if(getShareIntent().resolveActivity(requireActivity().packageManager)==null){
            //Then only display the button and fire the intent
            startActivity(getShareIntent())
       }

Enjoy


Thanks for reading!