MailTo

Added in 1.5.0

public final class MailTo


MailTo URI parser. Replacement for android.net.MailTo.

This class parses a mailto scheme URI and then can be queried for the parsed parameters. This implements RFC 6068.

Note: scheme name matching is case-sensitive, unlike the formal RFC. As a result, you should always ensure that you write your URI with the scheme using lower case letters, and normalize any URIs you receive from outside of Android to ensure the scheme is lower case.

Summary

Constants

static final String
MAILTO_SCHEME = "mailto:"

Public methods

@Nullable String

Retrieve the BCC address line from the parsed mailto URI.

@Nullable String

Retrieve the body line from the parsed mailto URI.

@Nullable String

Retrieve the CC address line from the parsed mailto URI.

@Nullable Map<StringString>

Retrieve all the parsed email headers from the mailto URI

@Nullable String

Retrieve the subject line from the parsed mailto URI.

@Nullable String

Retrieve the To address line from the parsed mailto URI.

static boolean

Test to see if the given string is a mailto URI

static boolean

Test to see if the given Uri is a mailto URI

static @NonNull MailTo

Parse and decode a mailto scheme string.

static @NonNull MailTo

Parse and decode a mailto scheme Uri.

@NonNull String

Constants

MAILTO_SCHEME

Added in 1.5.0
public static final String MAILTO_SCHEME = "mailto:"

Public methods

getBcc

Added in 1.5.0
public @Nullable String getBcc()

Retrieve the BCC address line from the parsed mailto URI. This could be several email address that are comma-space delimited. If no BCC line was specified, then null is return

Returns
@Nullable String

comma delimited email addresses or null

getBody

Added in 1.5.0
public @Nullable String getBody()

Retrieve the body line from the parsed mailto URI. If no body line was specified, then null is return

Returns
@Nullable String

body or null

getCc

Added in 1.5.0
public @Nullable String getCc()

Retrieve the CC address line from the parsed mailto URI. This could be several email address that are comma-space delimited. If no CC line was specified, then null is return

Returns
@Nullable String

comma delimited email addresses or null

getHeaders

Added in 1.5.0
public @Nullable Map<StringStringgetHeaders()

Retrieve all the parsed email headers from the mailto URI

Returns
@Nullable Map<StringString>

map containing all parsed values

getSubject

Added in 1.5.0
public @Nullable String getSubject()

Retrieve the subject line from the parsed mailto URI. If no subject line was specified, then null is return

Returns
@Nullable String

subject or null

getTo

Added in 1.5.0
public @Nullable String getTo()

Retrieve the To address line from the parsed mailto URI. This could be several email address that are comma-space delimited. If no To line was specified, then null is return

Returns
@Nullable String

comma delimited email addresses or null

isMailTo

Added in 1.5.0
public static boolean isMailTo(@Nullable String uri)

Test to see if the given string is a mailto URI

Note: scheme name matching is case-sensitive, unlike the formal RFC. As a result, you should always ensure that you write your URI string with the scheme using lower case letters, and normalize any URIs you receive from outside of Android to ensure the scheme is lower case.

Parameters
@Nullable String uri

string to be tested

Returns
boolean

true if the string is a mailto URI

isMailTo

Added in 1.5.0
public static boolean isMailTo(@Nullable Uri uri)

Test to see if the given Uri is a mailto URI

Note: scheme name matching is case-sensitive, unlike the formal RFC. As a result, you should always ensure that you write your Uri with the scheme using lower case letters, and normalize any Uris you receive from outside of Android to ensure the scheme is lower case.

Parameters
@Nullable Uri uri

Uri to be tested

Returns
boolean

true if the Uri is a mailto URI

parse

Added in 1.5.0
public static @NonNull MailTo parse(@NonNull String uri)

Parse and decode a mailto scheme string. This parser implements RFC 6068. The returned object can be queried for the parsed parameters.

Note: scheme name matching is case-sensitive, unlike the formal RFC. As a result, you should always ensure that you write your URI string with the scheme using lower case letters, and normalize any URIs you receive from outside of Android to ensure the scheme is lower case.

Parameters
@NonNull String uri

String containing a mailto URI

Returns
@NonNull MailTo

MailTo object

Throws
androidx.core.net.ParseException

if the scheme is not a mailto URI

parse

Added in 1.5.0
public static @NonNull MailTo parse(@NonNull Uri uri)

Parse and decode a mailto scheme Uri. This parser implements RFC 6068. The returned object can be queried for the parsed parameters.

Note: scheme name matching is case-sensitive, unlike the formal RFC. As a result, you should always ensure that you write your Uri with the scheme using lower case letters, and normalize any Uris you receive from outside of Android to ensure the scheme is lower case.

Parameters
@NonNull Uri uri

Uri containing a mailto URI

Returns
@NonNull MailTo

MailTo object

Throws
androidx.core.net.ParseException

if the scheme is not a mailto URI

toString

public @NonNull String toString()