使用Telegram发送消息
我正在尝试向电报应用程序用户发送消息,但意图仅打开电报应用程序 – 它不会选择一个conctact并发送消息:
public void shareTelegram(String message) { Intent waIntent = new Intent(Intent.ACTION_SEND); waIntent.setType("text/plain"); waIntent.setPackage("org.telegram.messenger"); if (waIntent != null) { waIntent.putExtra(Intent.EXTRA_TEXT, message);// startActivity(Intent.createChooser(waIntent, "Daniel")); } else { Toast.makeText(getApplicationContext(), "Telegram is not installed", Toast.LENGTH_SHORT).show(); } }
有没有办法完全发送邮件? 我可以完全发送信息而不显示电报吗?
TLSharp是C#上Telegram API的基本实现。 在此处查看https://github.com/sochix/TLSharp
尝试这个。
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(); }
- Java Generics – 这个语法是什么?
- 如何在Java中以编程方式获取文件权限模式
- Android StAX游标解析器 – 找不到方法javax.xml.stream.XMLInputFactory.newInstance
- FileNotFoundException Android logcat错误
- 数组适配器从Res文件夹加载图像(Android应用程序)
- validationAndroidManifest.xml文件
- 如何通过XML和Java代码使用OnClickListener接口?
- Android:在android中的Web视图中显示pdf从服务接收的字节
- 什么是在CursorLoader中的SDCARD中的Sqlite数据库的uri