MailTo
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 |
getBcc()Retrieve the BCC address line from the parsed mailto URI. |
@Nullable String |
getBody()Retrieve the body line from the parsed mailto URI. |
@Nullable String |
getCc()Retrieve the CC address line from the parsed mailto URI. |
@Nullable Map<String, String> |
Retrieve all the parsed email headers from the mailto URI |
@Nullable String |
Retrieve the subject line from the parsed mailto URI. |
@Nullable String |
getTo()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 |
toString() |
Constants
Public methods
getBcc
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
getBody
public @Nullable String getBody()
Retrieve the body line from the parsed mailto URI. If no body line was specified, then null is return
getCc
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
getHeaders
public @Nullable Map<String, String> getHeaders()
Retrieve all the parsed email headers from the mailto URI
getSubject
public @Nullable String getSubject()
Retrieve the subject line from the parsed mailto URI. If no subject line was specified, then null is return
getTo
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
isMailTo
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.
| Returns | |
|---|---|
boolean |
true if the string is a mailto URI |
isMailTo
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.
| Returns | |
|---|---|
boolean |
true if the Uri is a mailto URI |
parse
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.
| Throws | |
|---|---|
androidx.core.net.ParseException |
if the scheme is not a mailto URI |
parse
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.
| Throws | |
|---|---|
androidx.core.net.ParseException |
if the scheme is not a mailto URI |