Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open Telegram or Viber programmatically?

Tags:

java

android

Is it possible to open Telegram or Viber programmatically through a specific contact with message body? I found "how to open whatsapp": whatsapp. A similar solution may exist for Viber and Telegram!

like image 703
Vadim Fedchuk Avatar asked Apr 22 '26 20:04

Vadim Fedchuk


1 Answers

Regarding Telegram, you can do three things:

  • Open contact by url (https://t.me/usernameurl)
String user = "Telegram username";
Intent browserIntent = new Intent(Intent.ACTION_VIEW,Uri.parse("https://t.me/"+user));
startActivity(browserIntent);
  • The same but with the number doesn't work.
  • Use Telegram's bots api (if it solved your question, but I don't think so).

Relating Viber you are also able to do so. And, as with Telegram, you can't search by number. The needed uri can be found here (according to Viber):

Find your URI on your account's edit screen.

String user = "Viber public account uri";
String message = "Prefilled message"; // Not mandatory
Intent browserIntent = new Intent(Intent.ACTION_VIEW,Uri.parse("viber://pa?chatURI="+user+"&text="+message));
startActivity(browserIntent);
like image 111
miquelvir Avatar answered Apr 25 '26 11:04

miquelvir



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!