我想在android中发送带有多个附件的电子邮件,我得到了解决方案,但现在的问题是我有2个文件,一个在SDCard中,另一个在android的本地目录中,即Drawable文件夹。我在发送电子邮件时完成了编码,它显示了两个附件,但我只收到一个存在于 SD 卡中的附件,我无法从内部文件夹(即可绘制)中获取附件。下面是我的代码,请帮我解决这个问题。
public class TransmitAgreement extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_transmit_agreement);
String addressLine = gpsTracker.getAddressLine(this);
String emailaddress = "myemail";
String message = "Msg"
String subject = "sbj";
Intent emailIntent = new Intent(
android.content.Intent.ACTION_SEND_MULTIPLE);
emailIntent.setType("text/plain");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
new String[] { emailaddress });
emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(Intent.EXTRA_TEXT, message);
ArrayList<Uri> uris = new ArrayList<Uri>();
// convert from paths to Android friendly Parcelable Uri's
String[] filePaths = new String[] {
"android.resource://com.example.freenup/" + R.drawable.freenup_app_agreement,
"sdcard/saved_images/MyImage.png" };
for (String file : filePaths) {
File fileIn = new File(file);
Uri u = Uri.fromFile(fileIn);
uris.add(u);
}
emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.transmit_agreement, menu);
return true;
}
}
我也尝试过其他解决方案,但遇到了同样的问题。我在电子邮件中只收到一个附件...