How to launch Telegram app from my own android application?
Asked Answered
E

2

13

I have an android app that should be able to open a chat in the telegram app by pressing a button.
I want to open an existing robot chat page DIRECTLY from my app. I have a valid token for my robot. How can this be achieved?

Thanks in advance.

robot name : @InfotechAvl_bot

robot token: 179284***********

   //-------------
    case ContentFragment.lMenuTelegram:
     Intent LaunchIntent=getPackageManager().getLaunchIntentForPackage("org.telegram.messenger");
     startActivity(LaunchIntent);
            break;
Echino answered 1/3, 2016 at 11:41 Comment(2)
hope this will help you #30055701Spirogyra
actually i don't want sending message , i want to only open robot chat screen.Echino
E
27

To solve this problem you have to open robot id with this :

Intent telegram = new Intent(Intent.ACTION_VIEW , Uri.parse("https://telegram.me/InfotechAvl_bot"));
startActivity(telegram);
Echino answered 1/3, 2016 at 12:51 Comment(0)
M
3

for Instagram and Telegram and WhatsApp you can use this methods

 void getTelegram(){

        try {
            Intent telegramIntent = new Intent(Intent.ACTION_VIEW);
            telegramIntent.setData(Uri.parse("https://telegram.me/diako099"));
            startActivity(telegramIntent);
        } catch (Exception e) {
            // show error message
        }
    }

    void getInstagram(){
        try {
            Intent instagramIntent = new Intent(Intent.ACTION_VIEW);
            instagramIntent.setData(Uri.parse("https://www.instagram.com/diako_hasani99/"));
            startActivity(instagramIntent);
        } catch (Exception e) {
            // show error message
        }

    }

    void getWhatsApp(){
        try{

            String trimToNumner = "+989180074693"; //10 digit number
            Intent intent = new Intent ( Intent.ACTION_VIEW );
            intent.setData ( Uri.parse ( "https://wa.me/" + trimToNumner + "/?text=" + "" ) );
            startActivity ( intent );

        }catch (Exception e){

        }
    }
Monosyllable answered 22/12, 2019 at 12:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.