The function is working well in MainActivity.kt, but it has an error in a fragment.
- 1) Please kindly help and explain it.
2) I still not understand about the context issue, please kindly help to give any easy understanding link/information for me to read.
fun openYoutubeLink(youtubeID: String) { val intentApp = Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + youtubeID)) val intentBrowser = Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/watch?v=" + youtubeID)) try { this.startActivity(intentApp) } catch (ex: ActivityNotFoundException) { this.startActivity(intentBrowser) }
}