Android send message through telegram?

主宰稳场 提交于 2019-12-12 08:15:29

问题


I have installed the telegram app and just want to send a message (string) from my app through telegram to a contact.

All I found yet is in the question: How to send a Intent with telegram

with the code:

//Sending message
void intentMessageTelegram(String msg)
{
    final String appName = "org.telegram.messenger";
    final boolean isAppInstalled = isAppAvailable(this.getApplicationContext(), appName);
    if (isAppInstalled) 
    {
        Intent myIntent = new Intent(Intent.ACTION_SEND);
        myIntent.setType("text/plain");
        myIntent.setPackage(appName);
        myIntent.putExtra(Intent.EXTRA_TEXT, msg);//
        this.startActivity(Intent.createChooser(myIntent, "Kevin"));
    } 
    else 
    {
        Toast.makeText(this, "Telegram not Installed", Toast.LENGTH_SHORT).show();
    }
}

when I use that the telegram opens a contact list. But choosing multiple contacts, It is not sending it to them. If I click on one of them the message will be sent.

How can I send a message without displaying the telegram? Is there a way to read messages too?

Thanks in advance^^

来源:https://stackoverflow.com/questions/26684126/android-send-message-through-telegram

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!