2

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

irajDP
  • 31
  • 1
  • 7

1 Answers1

3

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)
Manish Karena
  • 724
  • 6
  • 29
akshay_shahane
  • 4,423
  • 2
  • 17
  • 30