Android URL Create buildEmailUri(String email, String subject, CharSequence body)

Here you can find the source of buildEmailUri(String email, String subject, CharSequence body)

Description

To be used with android.content.Intent.ACTION_SENDTO to send email, either in plain text or HTML.

License

Apache License

Parameter

Parameter Description
email The email address to send the message to
subject The email subject
body The email body

Return

The for the intent to send the email

Declaration

@Nonnull
public static Uri buildEmailUri(String email, String subject,
        CharSequence body) 

Method Source Code

//package com.java2s;
/*// ww  w .ja  v  a2  s  .  c o  m
 * Copyright 2013 Luluvise Ltd
 * Copyright 2013 Marco Salis - fast3r(at)gmail.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import javax.annotation.Nonnull;

import android.net.Uri;

public class Main {
    /**
     * To be used with {@link android.content.Intent.ACTION_SENDTO} to send
     * email, either in plain text or HTML.
     * 
     * @param email
     *            The email address to send the message to
     * @param subject
     *            The email subject
     * @param body
     *            The email body
     * @return The {@link Uri} for the intent to send the email
     */
    @Nonnull
    public static Uri buildEmailUri(String email, String subject,
            CharSequence body) {
        StringBuilder builder = new StringBuilder();
        builder.append("mailto:").append(email);
        builder.append("?subject=").append(subject);
        builder.append("&body=").append(body);
        String uriText = builder.toString().replace(" ", "%20");
        return Uri.parse(uriText);
    }
}

Related

  1. generateQueryJson(Map params)
  2. generateQueryString(Map params)
  3. mapToQueryString( HashMap queryString)
  4. buildQueries(String baseQuery, List datesByQueryIndex)
  5. url(String baseUrl, String relativePath)
  6. url(String baseUrl, String relativePath)
  7. createUrl(final String rootUrl, final String indivisualHost, final String featurePath, final int index, List pairs)
  8. buildBodyParameterString( List> parameters)