私の要件は、to、body、およびvcf添付ファイルを使用して、アプリケーションからデフォルトのAndroid画面を直接(アプリチューザーなしで)開く必要があることです。以下の2つの方法(アプローチ)を使用しています。しかし、最初のアプローチでは、添付ファイルが表示されますが、複数のアプリの選択画面が最初に表示され、次にメッセージングアプリを選択する必要があります。
2 番目のアプローチでは、デフォルトのメッセージング アプリは開いていますが、添付ファイル (.vcf) ファイルが来ていません。ご意見をお聞かせください。以下はコードです。
アプローチ 1:
public static void sendMMS(Context ctx,String firstname,String send_to,String body,String vcard)
{
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("text/x-vcard");
sendIntent.putExtra("address", send_to);
sendIntent.putExtra("sms_body", body);
File file1 = new File(Environment.getExternalStorageDirectory().getAbsolutePath(),firstname+".vcf");
sendIntent.putExtra(Intent.EXTRA_STREAM,
Uri.fromFile(file1));
((Activity) ctx).startActivity(sendIntent);
}
アプローチ 2:
private void sendMMS()
{
Intent smsIntent = new Intent(Intent.ACTION_SENDTO);
smsIntent.addCategory(Intent.CATEGORY_DEFAULT);
smsIntent.setType("vnd.android-dir/mms-sms");
File file1 = new File(Environment.getExternalStorageDirectory().getAbsolutePath(),"file.vcf");
smsIntent.putExtra(Intent.EXTRA_STREAM,
Uri.fromFile(file1));
smsIntent.setData(Uri.parse("sms:" + "XXXXXXXXXXX"));
startActivity(smsIntent);
}