Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.content.Context;
import android.content.Intent;
import android.net.Uri;

public class Main {
    /**
     * Propose user to send an email with pre-filled fields.
     */
    public static void sendEMail(final Context context, final String dialogTitle, final String to,
            final String subject, final String body) {
        final Intent send = new Intent(Intent.ACTION_SENDTO);
        final String uriText = "mailto:" + Uri.encode(to) + "?subject=" + Uri.encode(subject) + "&body="
                + Uri.encode(body);
        send.setData(Uri.parse(uriText));
        context.startActivity(Intent.createChooser(send, dialogTitle));
    }
}