I wanted to openUrl when someone clicked on the title in the recyclerview, but it showing an error for startActivity(intent).
override fun onBindViewHolder(holder: ItemHolder, position: Int) {
val itemModel: ItemModel = arrayList[position]
holder.title.text = itemModel.title
holder.source.text = itemModel.source
val url = itemModel.url
holder.title.setOnClickListener {
Toast.makeText(context, itemModel.title, Toast.LENGTH_LONG).show()
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse(url)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
startActivity(intent)
}
}