Using Telegram to send a message

旧街凉风 提交于 2019-12-04 07:14:05

TLSharp is basic implementation of Telegram API on C#. See it here https://github.com/sochix/TLSharp

Try this.

try {

            Toast.makeText(getApplicationContext(), "Sharing Via telegram !", Toast.LENGTH_LONG).show();
            Intent waIntent = new Intent(Intent.ACTION_SEND);
            waIntent.setType("image/*");
            waIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            PackageInfo info=pm.getPackageInfo("com.whatsapp", PackageManager.GET_META_DATA);//Check if package exists or not. If not then code

             waIntent.setPackage("org.telegram");  //package check whether telegram is installed
             waIntent.putExtra(Intent.EXTRA_TEXT, txt.getText().toString());//place your text here
             startActivity(Intent.createChooser(waIntent, "Share with"));
       } 
catch (PackageManager.NameNotFoundException e) 
{
            Toast.makeText(SingleItemView.this, "telegram not installed", Toast.LENGTH_SHORT).show();
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!