1

添付ファイル付きのメールを送信しようとしていますが、正常に動作しているコードが書かれていますが、ここにプログラムに添付したいファイル名を書きました。 sdcard.How からのユーザー。

    public class DemoVoiceActivity extends Activity {
        EditText txtTo,mSubject,mMessageBody,attachment;
        String strSubject,strMessageBody;
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            txtTo = (EditText)findViewById(R.id.to);

        mSubject = (EditText)findViewById(R.id.subject);
        mMessageBody = (EditText)findViewById(R.id.message_content);
        attachment=(EditText)findViewById(R.id.attachment);

        String[] strTo = {txtTo.getText().toString()};

        strSubject = mSubject.getText().toString();
        strMessageBody = mMessageBody.getText().toString();
        Intent objIntent = new Intent(android.content.Intent.ACTION_SEND);
        objIntent.putExtra(android.content.Intent.EXTRA_EMAIL, strTo);

        objIntent.setType("plain/text"); objIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, strSubject);
        objIntent.putExtra(android.content.Intent.EXTRA_TEXT, "MESSAGE"); objIntent.putExtra(android.content.Intent.EXTRA_STREAM,Uri.parse("file://"+Environment.getExternalStorageDirectory()+"/q.mp4"));
        startActivity(objIntent);
        finish();
    }
}
4

1 に答える 1

1

この回答をチェックして ください https://stackoverflow.com/a/7857102/975959

彼は、シンプルなファイル チューザー オープン ソース ライブラリを提供しました。次に、onFileSelect()メソッドでファイル パスを取得し、objIntent.

また、必要に応じて、自分で実装する方法も提供します。

于 2012-08-08T13:48:58.333 に答える