小编Sou*_*hak的帖子

Android将多个文件从SD卡附加到电子邮件

如何在android中的电子邮件中附加多个文件?多个文件附加到意图是否需要任何权限?我正在尝试使用putParcelableArrayListExtra(Intent.EXTRA_STREAM,ArrayList uriList)方法,但仍然怀疑Uri类是否<?扩展Parcelable>或不.我无法将任何文件附加到电子邮件中.

这是我的代码::

Intent sendIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
sendIntent.setType("plain/text");
sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {"soubhabpathak2010@gmail.com"});
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Accident Capture");
sendIntent.putExtra(Intent.EXTRA_TEXT, emailBody);

ArrayList<Uri> uriList = getUriListForImages();
sendIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uriList);
Log.d(TAG, "Size of the ArrayList :: " +uriList.size());
FormHolderActivity.this.startActivity(Intent.createChooser(sendIntent, "Email:"));
Run Code Online (Sandbox Code Playgroud)

和getUriListForImages()这个方法被定义为吼叫-----


private ArrayList<Uri> getUriListForImages()  {

    ArrayList<Uri> uriList = new ArrayList<Uri>();
    String imageDirectoryPath =  Environment.getExternalStorageDirectory().getAbsolutePath()+ "/accident/";
    File imageDirectory = new File(imageDirectoryPath);
    String[] fileList = imageDirectory.list();

    if(fileList.length != 0) {
        for(int i=0; i<fileList.length; i++)
        {
            String file = "file://" + imageDirectoryPath + fileList[i];
            Log.d(TAG, "File name for …
Run Code Online (Sandbox Code Playgroud)

email android attachment

4
推荐指数
1
解决办法
3827
查看次数

标签 统计

android ×1

attachment ×1

email ×1