0
有時我會看到沒有附件的電子郵件。發送附件始終不起作用
我懷疑這發生在文件大小比處理程序大的時候。
我發送碼 -
Intent email = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
email.putExtra(Intent.EXTRA_SUBJECT, "Device Logs");
email.setType("text/plain");
email.putExtra(Intent.EXTRA_TEXT, getEmailContents());
File file = writeLogFile();
ArrayList<Uri> uriList = new ArrayList<Uri>();
Uri uri = Uri.fromFile(file);
uriList.add(uri);
email.putExtra(Intent.EXTRA_STREAM, uriList);
startActivity(Intent.createChooser(email, "Choose an Email client :"));
文件代碼 -
public File writeLogFile()
{
if(builder != null)
{
for(int i =0;i <receiptlist.size();i++)
{
builder.append(receiptlist.get(i) + "\n");
}
}
//to create a Text file name "logcat.txt" in SDCard
File sdCard = Environment.getExternalStorageDirectory();
File dir = new File (sdCard.getAbsolutePath() + "/myLogcat");
if(!dir.exists())
dir.mkdirs();
File file = new File(dir, "logcat.txt");
try {
//to write logcat in text file
FileOutputStream fOut = new FileOutputStream(file);
OutputStreamWriter osw = new OutputStreamWriter(fOut);
// Write the string to the file
osw.write(builder.toString());
osw.flush();
osw.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return file;
}
我在做什麼錯?