使用发送意图android向多个人发送消息 [英] Sending message to Multiple Persons using send intent android

查看:104
本文介绍了使用发送意图android向多个人发送消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从我的应用程序中使用android共享意图.

I am trying to use the android share intent from my application.

我已在我的应用程序中列出了来自我的联系人内容提供者的所有联系人. 现在我想使用任何消息应用程序将消息发送给我在我的应用程序中选择的所有联系人 安装在用户手机中.

I have listed all the contacts from my contacts content provider in my application. Now i want to send message to all the contacts i have selected(in my app) using any of the message app installed in user phone.

我不想使用smsmaanger,只是想在用户手机中使用任何发送短信的应用程序,如果 可用的. 我尝试使用电子邮件可以很好地工作,但不适用于短信.

I do not want to user smsmaanger , simply want to user any sms sending application in user mobile if available. I tried to do with email works great but not with sms .

我尝试使用电子邮件效果很好

I tried with email as works great

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();
    }
}

对于短信,我使用的是这种方式.

For sms i am using like this .

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();
    }
}

我只想将我的所有联系人添加到用户消息应用程序中以发送消息,并附带一条消息 可能

I just simply want to add my all contacts to users message app for sending message, with a message possible

推荐答案

要将SMS发送到多个号码,您需要使用;
分隔号码 此处的示例:

To send SMS to multiple numbers you need to separate the numbers with ;
Sample here:

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

...

sendIntent.putExtra(android.content.Intent.EXTRA_PHONE_NUMBER, toNumbers);

这篇关于使用发送意图android向多个人发送消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆