使用send intent android向多人发送消息
我正在尝试从我的应用程序中使用android共享意图 我已在应用程序中列出了联系人内容提供商提供的所有联系人。 现在,我想使用任何消息应用程序向我选择的所有联系人(在我的应用程序中)发送消息 安装在用户电话中 我不想用户短信愤怒,只是想用户任何短信发送应用程序在用户手机如果 可用。 我试着用电子邮件工作,但不是用短信 我试过用电子邮件,效果很好使用send intent android向多人发送消息,android,android-intent,Android,Android Intent,我正在尝试从我的应用程序中使用android共享意图 我已在应用程序中列出了联系人内容提供商提供的所有联系人。 现在,我想使用任何消息应用程序向我选择的所有联系人(在我的应用程序中)发送消息 安装在用户电话中 我不想用户短信愤怒,只是想用户任何短信发送应用程序在用户手机如果 可用。 我试着用电子邮件工作,但不是用短信 我试过用电子邮件,效果很好 public static void send(Context ctx, String[] addy, String subject,
public static void send(Context ctx, String[] addy, String subject,
String body,File attachment) {
try {
Intent sendIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
sendIntent.setType("message/rfc822");
sendIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
addy);
sendIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
sendIntent.putExtra(android.content.Intent.EXTRA_TEXT, body);
//sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(attachment));
ctx.startActivity(Intent.createChooser(sendIntent,
"Send via which Application?"));
} catch (Exception e) {
Toast.makeText(ctx, "No activity was found to handle this action",
Toast.LENGTH_SHORT).show();
}
}
对于短信,我是这样使用的
public static void send(Context ctx, String addy, String subject,
String body,File attachment) {
try {
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setType("vnd.android-dir/mms-sms");
sendIntent.putExtra(android.content.Intent.EXTRA_PHONE_NUMBER,
addy);
sendIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
sendIntent.putExtra(android.content.Intent.EXTRA_TEXT, body);
//sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(attachment));
ctx.startActivity(Intent.createChooser(sendIntent,
"Send via which Application?"));
} catch (Exception e) {
Toast.makeText(ctx, "No activity was found to handle this action",
Toast.LENGTH_SHORT).show();
}
}
我只是想把我的所有联系人添加到用户消息应用程序中,以便发送消息,同时发送一条消息
可能要向多个号码发送短信,您需要用
分隔这些号码代码>
此处示例:
String toNumbers = "";
ArrayList<String> numbersArrayList;// your phone numbers here
for ( String number : numbersArrayList)
{
toNumbers = toNumbers + number + ";"//separating numbers with semicolon
}
toNumbers = toNumbers.subString(0, toNumbers.length - 1);// remove the last semicolon
尝试下面粘贴的链接。[向多个联系人发送短信。][1][1]:@trushitsah Yes buddy非常有用完整链接谢谢
sendIntent.putExtra(android.content.Intent.EXTRA_PHONE_NUMBER, toNumbers);