0

私はたくさん検索しましたが、私がしなければならないようなことにつまずきませんでした。クリックしてメール ファイルを送信すると、添付ファイルとして表示されますが、添付ファイルを受信しません URL として受信した添付ファイルを送信する特別な方法はありますか? ここに私の活動コードがあります: http://pastebin.com/uzdJYxab[2] そしてここに私のプロジェクトがあります https://docs.google.com/file/d/0B-91m-6ZevwCRTYtYXRGb3l6UVE/edit?usp=sharing Code for 「メール送信」ボタン: sendEmail_button.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View v) {
                            // TODO Auto-generated method stub
                            Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
                            intent.setType("*/*");
                            intent.putExtra(Intent.EXTRA_SUBJECT, "Attachment from app");
                            intent.putExtra(Intent.EXTRA_TEXT, "Sending mp3 file " + title);

                            intent.putExtra(Intent.EXTRA_EMAIL, new String[] {"some_email@email.com"});
                            ArrayList<Uri> uris = new ArrayList<Uri>();

                            uris.add(Uri.fromFile(new File(trackUrl)));

                            intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);

                            startActivity(Intent.createChooser(intent, "Send mail"));
                    }
            });    

URL からインテントにオーディオ ファイルを配置するには、別の方法が必要ではないでしょうか。私はインテント.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uri);を使用する必要があります。私の仕事の一部として。しかし、私は別の部分をスキップしました

ACTION_SEND_MULTIPLE は、サウンド ファイルにアクセスする外部アクティビティを使用します。このようなアクセスを許可するには、次のことが必要です。 - ContentProvider を作成します。- public ParcelFileDescriptor openFile(Uri uri, String mode) をオーバーライド

これは、コンテンツ プロバイダーを使用する場合にのみ、URL からファイルを電子メールの添付ファイルとして取得および配置できるということですか? 私はグーグルで検索しましたが、 public ParcelFileDescriptor openFile(Uri uri, String mode) を正しくオーバーライドする方法が見つかりませんでした。誰かが少なくとも私を正しい方向に向けてくれるでしょうか? 繰り返しますが、これを解決するように求めているわけではありませんが、少なくとも間違いを指摘し、アドバイスをしてください。

4

1 に答える 1

0

ファイルがパブリック ディレクトリにある場合、コンテンツ プロバイダーは必要ありません。私はこのようにします:

private void launchShareActivity(final List<String> exported_filenames) {
    Log.v(DEBUG_TAG, "launchShareActivity");
    final Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
    intent.setType("*/*");
    if (exported_filenames.size() == 0) {
        Log.i(DEBUG_TAG, "there no file to share");
        return;
    }
    final ArrayList<Uri> uris = new ArrayList<Uri>();
    for (final String exported_file : exported_filenames) {
        final File f = new File(exported_file);
        uris.add(Uri.fromFile(f));
    }
    intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
    activity.startActivity(Intent.createChooser(intent, "Send page"));
}
于 2013-07-31T20:53:16.303 に答える