安卓 - 发送电报消息到特定号码
我正在尝试从我的Android应用程序中向特定号码发送电报消息。现在我的代码启动Telegram应用程序,然后用户必须选择destinatary。我想做的是将消息发送到指定的号码,而无需用户选择联系人。我的代码如下:
/**
* Intent to send a telegram message
* @param msg
*/
void intentMessageTelegram(String msg)
{
final String appName = "org.telegram.messenger";
final boolean isAppInstalled = isAppAvailable(mUIActivity.getApplicationContext(), appName);
if (isAppInstalled)
{
Intent myIntent = new Intent(Intent.ACTION_SEND);
myIntent.setType("text/plain");
myIntent.setPackage(appName);
myIntent.putExtra(Intent.EXTRA_TEXT, msg);//
mUIActivity.startActivity(Intent.createChooser(myIntent, "Share with"));
}
else
{
Toast.makeText(mUIActivity, "Telegram not Installed", Toast.LENGTH_SHORT).show();
}
}