【发布时间】:2013-10-22 16:01:26
【问题描述】:
我正在尝试使用我的应用程序中的 android 共享意图。
我已在我的应用程序中列出了来自我的联系人内容提供商的所有联系人。 现在我想使用任何消息应用程序向我选择的所有联系人(在我的应用程序中)发送消息 安装在用户手机中。
我不想使用 smsmaanger ,只是想在用户手机中使用任何短信发送应用程序,如果 可用的。 我尝试使用电子邮件效果很好,但不适用于短信。
我尝试使用电子邮件,效果很好
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();
}
}
我只是想将我的所有联系人添加到用户消息应用程序以发送消息,并带有消息 可能
【问题讨论】:
-
试试下面粘贴的链接。 [向多个联系人发送短信。][1] [1]:stackoverflow.com/questions/16771470/…
-
@TrushitShah 是的哥们非常有用的链接谢谢