0
私のコードを読んだり再読したりしても問題ないですが、電子メールは添付ファイルなしで送信されます。添付ファイルなしで電子メールが正しく送信されない
メールアクティビティを呼び出す前に、ファイル(readFile())を再読み込みすることさえできます。
私のコードの何が問題になっている:
private void sndRecMail(){
btnSend = (Button) findViewById(R.id.send);
btnSend.setVisibility(View.VISIBLE);
btnSend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String subject = "file vendors";
Intent email = new Intent(Intent.ACTION_SEND);
email.setType("*/*");
email.putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
email.putExtra(Intent.EXTRA_SUBJECT, subject);
email.putExtra(Intent.EXTRA_TEXT, message);
String dir = context.getFilesDir().getAbsolutePath();
fi = new File(dir, "vendors.txt");
if (!fi.exists() || !fi.canRead())
return;
readFile(); // check if file is not empty and readable!!!
Uri uri = Uri.fromFile(fi);
email.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(email, "Select Email Client"));
}
});
}
'readFileの();' 1何戻り値をチェックせずに読み込みができない場合に返しても意味がありますか? – greenapps
'getFilesDir()'は、あなたのアプリケーションのための私設内部メモリです。電子メールアプリはそれから読むことができません。 – greenapps
1番目のコメント:私は怠け者でした。デバッガを調べました。 2番目のコメント:私はそれが問題だと思います。私は – narb