アプリケーションから 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();
}
}
メッセージを送信するために、すべての連絡先をユーザーのメッセージアプリに追加したいだけです。