0

アプリケーションから Android 共有インテントを使用しようとしています。

連絡先コンテンツ プロバイダーからのすべての連絡先をアプリケーションに一覧表示しました。今、ユーザーの電話にインストールされているメッセージアプリのいずれかを使用して、(アプリで) 選択したすべての連絡先にメッセージを送信したいと考えています。

私は smsmaanger を使用したくありません。利用可能な場合は、ユーザーのモバイルでアプリケーションを送信する SMS を使用したいだけです。私は電子メールでやろうとしましたが、SMSではうまくいきません。

私はうまくいくように電子メールで試しました

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

SMSの場合、私はこのように使用しています。

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

メッセージを送信するために、すべての連絡先をユーザーのメッセージアプリに追加したいだけです。

4

1 に答える 1

2

;
SMS を複数の番号に送信するには、次のサンプルで 番号を区切る必要があります。

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);
于 2013-10-22T08:01:26.890 に答える