ShareCompat.IntentBuilder
public class ShareCompat.IntentBuilder
IntentBuilder is a helper for constructing ACTION_SEND and ACTION_SEND_MULTIPLE sharing intents and starting activities to share content. The ComponentName and package name of the calling activity will be included.
Summary
Public constructors |
|---|
IntentBuilder(@NonNull Context launchingContext)Create a new IntentBuilder for launching a sharing action from launchingContext. |
Public methods |
|
|---|---|
@NonNull ShareCompat.IntentBuilder |
addEmailBcc(@NonNull String address)Add an email address to be used in the "bcc" field of the final Intent. |
@NonNull ShareCompat.IntentBuilder |
addEmailBcc(@NonNull String[] addresses)Add an array of email addresses to be used in the "bcc" field of the final Intent. |
@NonNull ShareCompat.IntentBuilder |
addEmailCc(@NonNull String address)Add an email address to be used in the "cc" field of the final Intent. |
@NonNull ShareCompat.IntentBuilder |
addEmailCc(@NonNull String[] addresses)Add an array of email addresses to be used in the "cc" field of the final Intent. |
@NonNull ShareCompat.IntentBuilder |
addEmailTo(@NonNull String address)Add an email address to be used in the "to" field of the final Intent. |
@NonNull ShareCompat.IntentBuilder |
addEmailTo(@NonNull String[] addresses)Add an array of email addresses to be used in the "to" field of the final Intent. |
@NonNull ShareCompat.IntentBuilder |
Add a stream URI to the data that should be shared. |
@NonNull Intent |
Create an Intent that will launch the standard Android activity chooser, allowing the user to pick what activity/app on the system should handle the share. |
static @NonNull ShareCompat.IntentBuilder |
This method is deprecated. Use the constructor of IntentBuilder |
@NonNull Intent |
Retrieve the Intent as configured so far by the IntentBuilder. |
@NonNull ShareCompat.IntentBuilder |
setChooserTitle(@StringRes int resId)Set the title that will be used for the activity chooser for this share. |
@NonNull ShareCompat.IntentBuilder |
setChooserTitle(@Nullable CharSequence title)Set the title that will be used for the activity chooser for this share. |
@NonNull ShareCompat.IntentBuilder |
setEmailBcc(@Nullable String[] addresses)Set an array of email addresses to BCC on this share. |
@NonNull ShareCompat.IntentBuilder |
setEmailCc(@Nullable String[] addresses)Set an array of email addresses to CC on this share. |
@NonNull ShareCompat.IntentBuilder |
setEmailTo(@Nullable String[] addresses)Set an array of email addresses as recipients of this share. |
@NonNull ShareCompat.IntentBuilder |
setHtmlText(@Nullable String htmlText)Set an HTML string to be sent as part of the share. |
@NonNull ShareCompat.IntentBuilder |
setIntentSender(@Nullable IntentSender intentSender)Set the IntentSender that will be used for the activity chooser callback when the user makes a choice. |
@NonNull ShareCompat.IntentBuilder |
Set a stream URI to the data that should be shared. |
@NonNull ShareCompat.IntentBuilder |
setSubject(@Nullable String subject)Set a subject heading for this share; useful for sharing via email. |
@NonNull ShareCompat.IntentBuilder |
setText(@Nullable CharSequence text)Set the literal text data to be sent as part of the share. |
@NonNull ShareCompat.IntentBuilder |
Set the type of data being shared |
void |
Start a chooser activity for the current share intent. |
Public constructors
IntentBuilder
public IntentBuilder(@NonNull Context launchingContext)
Create a new IntentBuilder for launching a sharing action from launchingContext.
Note that builders that are not constructed with an Activity context (or a wrapped activity context) will not set the calling activity on the returned intent.
Public methods
addEmailBcc
public @NonNull ShareCompat.IntentBuilder addEmailBcc(@NonNull String address)
Add an email address to be used in the "bcc" field of the final Intent.
| Returns | |
|---|---|
@NonNull ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
EXTRA_BCC |
addEmailBcc
public @NonNull ShareCompat.IntentBuilder addEmailBcc(@NonNull String[] addresses)
Add an array of email addresses to be used in the "bcc" field of the final Intent.
| Parameters | |
|---|---|
@NonNull String[] addresses |
Email addresses to BCC |
| Returns | |
|---|---|
@NonNull ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
EXTRA_BCC |
addEmailCc
public @NonNull ShareCompat.IntentBuilder addEmailCc(@NonNull String address)
Add an email address to be used in the "cc" field of the final Intent.
| Returns | |
|---|---|
@NonNull ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
EXTRA_CC |
addEmailCc
public @NonNull ShareCompat.IntentBuilder addEmailCc(@NonNull String[] addresses)
Add an array of email addresses to be used in the "cc" field of the final Intent.
| Parameters | |
|---|---|
@NonNull String[] addresses |
Email addresses to CC |
| Returns | |
|---|---|
@NonNull ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
EXTRA_CC |
addEmailTo
public @NonNull ShareCompat.IntentBuilder addEmailTo(@NonNull String address)
Add an email address to be used in the "to" field of the final Intent.
| Returns | |
|---|---|
@NonNull ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
EXTRA_EMAIL |
addEmailTo
public @NonNull ShareCompat.IntentBuilder addEmailTo(@NonNull String[] addresses)
Add an array of email addresses to be used in the "to" field of the final Intent.
| Parameters | |
|---|---|
@NonNull String[] addresses |
Email addresses to send to |
| Returns | |
|---|---|
@NonNull ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
EXTRA_EMAIL |
addStream
public @NonNull ShareCompat.IntentBuilder addStream(@NonNull Uri streamUri)
Add a stream URI to the data that should be shared. If this is not the first stream URI added the final intent constructed will become an ACTION_SEND_MULTIPLE intent. Not all apps will handle both ACTION_SEND and ACTION_SEND_MULTIPLE.
| Returns | |
|---|---|
@NonNull ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
EXTRA_STREAM |
|
ACTION_SEND |
|
ACTION_SEND_MULTIPLE |
createChooserIntent
public @NonNull Intent createChooserIntent()
Create an Intent that will launch the standard Android activity chooser, allowing the user to pick what activity/app on the system should handle the share.
public static @NonNull ShareCompat.IntentBuilderfrom(@NonNull Activity launchingActivity)
Create a new IntentBuilder for launching a sharing action from launchingActivity.
| Returns | |
|---|---|
@NonNull ShareCompat.IntentBuilder |
a new IntentBuilder instance |
getIntent
public @NonNull Intent getIntent()
Retrieve the Intent as configured so far by the IntentBuilder. This Intent is suitable for use in a ShareActionProvider or chooser dialog.
To create an intent that will launch the activity chooser so that the user may select a target for the share, see createChooserIntent.
setChooserTitle
public @NonNull ShareCompat.IntentBuilder setChooserTitle(@StringRes int resId)
Set the title that will be used for the activity chooser for this share.
| Parameters | |
|---|---|
@StringRes int resId |
Resource ID of the title string to use |
| Returns | |
|---|---|
@NonNull ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
setChooserTitle
public @NonNull ShareCompat.IntentBuilder setChooserTitle(@Nullable CharSequence title)
Set the title that will be used for the activity chooser for this share.
| Parameters | |
|---|---|
@Nullable CharSequence title |
Title string |
| Returns | |
|---|---|
@NonNull ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
setEmailBcc
public @NonNull ShareCompat.IntentBuilder setEmailBcc(@Nullable String[] addresses)
Set an array of email addresses to BCC on this share. This replaces all current "BCC" recipients that have been set so far.
| Parameters | |
|---|---|
@Nullable String[] addresses |
Email addresses to BCC on the share |
| Returns | |
|---|---|
@NonNull ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
EXTRA_BCC |
setEmailCc
public @NonNull ShareCompat.IntentBuilder setEmailCc(@Nullable String[] addresses)
Set an array of email addresses to CC on this share. This replaces all current "CC" recipients that have been set so far.
| Parameters | |
|---|---|
@Nullable String[] addresses |
Email addresses to CC on the share |
| Returns | |
|---|---|
@NonNull ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
EXTRA_CC |
setEmailTo
public @NonNull ShareCompat.IntentBuilder setEmailTo(@Nullable String[] addresses)
Set an array of email addresses as recipients of this share. This replaces all current "to" recipients that have been set so far.
| Parameters | |
|---|---|
@Nullable String[] addresses |
Email addresses to send to |
| Returns | |
|---|---|
@NonNull ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
EXTRA_EMAIL |
setHtmlText
public @NonNull ShareCompat.IntentBuilder setHtmlText(@Nullable String htmlText)
Set an HTML string to be sent as part of the share. If EXTRA_TEXT has not already been supplied, a styled version of the supplied HTML text will be added as EXTRA_TEXT as parsed by Html.fromHtml.
| Parameters | |
|---|---|
@Nullable String htmlText |
A string containing HTML markup as a richer version of the text provided by EXTRA_TEXT. |
| Returns | |
|---|---|
@NonNull ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
setText |
setIntentSender
public @NonNull ShareCompat.IntentBuilder setIntentSender(@Nullable IntentSender intentSender)
Set the IntentSender that will be used for the activity chooser callback when the user makes a choice.
| Parameters | |
|---|---|
@Nullable IntentSender intentSender |
IntentSender to use |
| Returns | |
|---|---|
@NonNull ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
setStream
public @NonNull ShareCompat.IntentBuilder setStream(@Nullable Uri streamUri)
Set a stream URI to the data that should be shared.
This replaces all currently set stream URIs and will produce a single-stream ACTION_SEND intent.
| Returns | |
|---|---|
@NonNull ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
EXTRA_STREAM |
setSubject
public @NonNull ShareCompat.IntentBuilder setSubject(@Nullable String subject)
Set a subject heading for this share; useful for sharing via email.
| Returns | |
|---|---|
@NonNull ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
EXTRA_SUBJECT |
setText
public @NonNull ShareCompat.IntentBuilder setText(@Nullable CharSequence text)
Set the literal text data to be sent as part of the share. This may be a styled CharSequence.
| Parameters | |
|---|---|
@Nullable CharSequence text |
Text to share |
| Returns | |
|---|---|
@NonNull ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
EXTRA_TEXT |
setType
public @NonNull ShareCompat.IntentBuilder setType(@Nullable String mimeType)
Set the type of data being shared
| Returns | |
|---|---|
@NonNull ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
setType |
startChooser
public void startChooser()
Start a chooser activity for the current share intent.