Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.content.Intent;

import android.net.Uri;

import java.util.ArrayList;

public class Main {
    public static Intent newSendMultipleAttachmentsIntent(String emailAddress, String subject, String contentBody,
            ArrayList<Uri> uris) {

        final Intent ei = new Intent(Intent.ACTION_SEND_MULTIPLE);
        ei.setType("plain/text");
        ei.putExtra(Intent.EXTRA_EMAIL, new String[] { emailAddress });
        ei.putExtra(Intent.EXTRA_SUBJECT, subject);

        //ei.putExtra(Intent.EXTRA_TEXT, contentBody);
        //fix for ClassCastException with Intent.EXTRA_TEXT : https://code.google.com/p/android/issues/detail?id=38303
        //: use list of string not a string
        ArrayList<String> extra_text = new ArrayList<String>();
        extra_text.add(contentBody);
        ei.putExtra(Intent.EXTRA_TEXT, extra_text);

        ei.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);

        return ei;
    }
}