public class

ShareCompat.IntentBuilder

extends java.lang.Object

 java.lang.Object

↳androidx.core.app.ShareCompat.IntentBuilder

Overview

IntentBuilder is a helper for constructing and sharing intents and starting activities to share content. The ComponentName and package name of the calling activity will be included.

Summary

Constructors
publicIntentBuilder(Context launchingContext)

Create a new IntentBuilder for launching a sharing action from launchingContext.

Methods
public ShareCompat.IntentBuilderaddEmailBcc(java.lang.String address)

Add an email address to be used in the "bcc" field of the final Intent.

public ShareCompat.IntentBuilderaddEmailBcc(java.lang.String addresses[])

Add an array of email addresses to be used in the "bcc" field of the final Intent.

public ShareCompat.IntentBuilderaddEmailCc(java.lang.String address)

Add an email address to be used in the "cc" field of the final Intent.

public ShareCompat.IntentBuilderaddEmailCc(java.lang.String addresses[])

Add an array of email addresses to be used in the "cc" field of the final Intent.

public ShareCompat.IntentBuilderaddEmailTo(java.lang.String address)

Add an email address to be used in the "to" field of the final Intent.

public ShareCompat.IntentBuilderaddEmailTo(java.lang.String addresses[])

Add an array of email addresses to be used in the "to" field of the final Intent.

public ShareCompat.IntentBuilderaddStream(Uri streamUri)

Add a stream URI to the data that should be shared.

public IntentcreateChooserIntent()

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 ShareCompat.IntentBuilderfrom(Activity launchingActivity)

Create a new IntentBuilder for launching a sharing action from launchingActivity.

public IntentgetIntent()

Retrieve the Intent as configured so far by the IntentBuilder.

public ShareCompat.IntentBuildersetChooserTitle(java.lang.CharSequence title)

Set the title that will be used for the activity chooser for this share.

public ShareCompat.IntentBuildersetChooserTitle(int resId)

Set the title that will be used for the activity chooser for this share.

public ShareCompat.IntentBuildersetEmailBcc(java.lang.String addresses[])

Set an array of email addresses to BCC on this share.

public ShareCompat.IntentBuildersetEmailCc(java.lang.String addresses[])

Set an array of email addresses to CC on this share.

public ShareCompat.IntentBuildersetEmailTo(java.lang.String addresses[])

Set an array of email addresses as recipients of this share.

public ShareCompat.IntentBuildersetHtmlText(java.lang.String htmlText)

Set an HTML string to be sent as part of the share.

public ShareCompat.IntentBuildersetStream(Uri streamUri)

Set a stream URI to the data that should be shared.

public ShareCompat.IntentBuildersetSubject(java.lang.String subject)

Set a subject heading for this share; useful for sharing via email.

public ShareCompat.IntentBuildersetText(java.lang.CharSequence text)

Set the literal text data to be sent as part of the share.

public ShareCompat.IntentBuildersetType(java.lang.String mimeType)

Set the type of data being shared

public voidstartChooser()

Start a chooser activity for the current share intent.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public IntentBuilder(Context launchingContext)

Create a new IntentBuilder for launching a sharing action from launchingContext.

Note that builders that are not constructed with an context (or a wrapped activity context) will not set the calling activity on the returned intent.

Parameters:

launchingContext: Context that the share will be launched from

Methods

public static ShareCompat.IntentBuilder from(Activity launchingActivity)

Deprecated: Use the constructor of IntentBuilder

Create a new IntentBuilder for launching a sharing action from launchingActivity.

Parameters:

launchingActivity: Activity that the share will be launched from

Returns:

a new IntentBuilder instance

public 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 ShareCompat.IntentBuilder.createChooserIntent().

Returns:

The current Intent being configured by this builder

public 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.

Returns:

A chooser Intent for the currently configured sharing action

public void startChooser()

Start a chooser activity for the current share intent.

public ShareCompat.IntentBuilder setChooserTitle(java.lang.CharSequence title)

Set the title that will be used for the activity chooser for this share.

Parameters:

title: Title string

Returns:

This IntentBuilder for method chaining

public ShareCompat.IntentBuilder setChooserTitle(int resId)

Set the title that will be used for the activity chooser for this share.

Parameters:

resId: Resource ID of the title string to use

Returns:

This IntentBuilder for method chaining

public ShareCompat.IntentBuilder setType(java.lang.String mimeType)

Set the type of data being shared

Parameters:

mimeType: mimetype of the shared data

Returns:

This IntentBuilder for method chaining

See also:

public ShareCompat.IntentBuilder setText(java.lang.CharSequence text)

Set the literal text data to be sent as part of the share. This may be a styled CharSequence.

Parameters:

text: Text to share

Returns:

This IntentBuilder for method chaining

See also:

public ShareCompat.IntentBuilder setHtmlText(java.lang.String htmlText)

Set an HTML string to be sent as part of the share. If 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:

htmlText: A string containing HTML markup as a richer version of the text provided by EXTRA_TEXT.

Returns:

This IntentBuilder for method chaining

See also: ShareCompat.IntentBuilder.setText(CharSequence)

public ShareCompat.IntentBuilder setStream(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.

Parameters:

streamUri: URI of the stream to share

Returns:

This IntentBuilder for method chaining

See also:

public ShareCompat.IntentBuilder addStream(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.

Parameters:

streamUri: URI of the stream to share

Returns:

This IntentBuilder for method chaining

See also:

public ShareCompat.IntentBuilder setEmailTo(java.lang.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:

addresses: Email addresses to send to

Returns:

This IntentBuilder for method chaining

See also:

public ShareCompat.IntentBuilder addEmailTo(java.lang.String address)

Add an email address to be used in the "to" field of the final Intent.

Parameters:

address: Email address to send to

Returns:

This IntentBuilder for method chaining

See also:

public ShareCompat.IntentBuilder addEmailTo(java.lang.String addresses[])

Add an array of email addresses to be used in the "to" field of the final Intent.

Parameters:

addresses: Email addresses to send to

Returns:

This IntentBuilder for method chaining

See also:

public ShareCompat.IntentBuilder setEmailCc(java.lang.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:

addresses: Email addresses to CC on the share

Returns:

This IntentBuilder for method chaining

See also:

public ShareCompat.IntentBuilder addEmailCc(java.lang.String address)

Add an email address to be used in the "cc" field of the final Intent.

Parameters:

address: Email address to CC

Returns:

This IntentBuilder for method chaining

See also:

public ShareCompat.IntentBuilder addEmailCc(java.lang.String addresses[])

Add an array of email addresses to be used in the "cc" field of the final Intent.

Parameters:

addresses: Email addresses to CC

Returns:

This IntentBuilder for method chaining

See also:

public ShareCompat.IntentBuilder setEmailBcc(java.lang.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:

addresses: Email addresses to BCC on the share

Returns:

This IntentBuilder for method chaining

See also:

public ShareCompat.IntentBuilder addEmailBcc(java.lang.String address)

Add an email address to be used in the "bcc" field of the final Intent.

Parameters:

address: Email address to BCC

Returns:

This IntentBuilder for method chaining

See also:

public ShareCompat.IntentBuilder addEmailBcc(java.lang.String addresses[])

Add an array of email addresses to be used in the "bcc" field of the final Intent.

Parameters:

addresses: Email addresses to BCC

Returns:

This IntentBuilder for method chaining

See also:

public ShareCompat.IntentBuilder setSubject(java.lang.String subject)

Set a subject heading for this share; useful for sharing via email.

Parameters:

subject: Subject heading for this share

Returns:

This IntentBuilder for method chaining

See also: