Kotlin - How to open link of Telegram group into Telegram app

Viewed 1112

I have a group link of Telegram. What I want is when i click on the button them i want to open that like into the telegram app instead of browser(Currently it is opened in browser).

Here is the code that i have tried to make it possible :

val group_telegram = Intent (ACTION_VIEW, Uri.parse("https://t.me/name_group"))
startActivity(group_telegram)

Thanks

1 Answers

You can check if telegram app is installed on user device by using setPackage() method like below.

val telegram = Intent(Intent.ACTION_VIEW, Uri.parse("https://t.me/name_group"))
        telegram.setPackage("org.telegram.messenger")
        startActivity(telegram)
Related