ShareCompat.IntentBuilder
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(launchingContext: Context)Create a new IntentBuilder for launching a sharing action from launchingContext. |
Public functions |
|
|---|---|
ShareCompat.IntentBuilder |
addEmailBcc(address: String)Add an email address to be used in the "bcc" field of the final Intent. |
ShareCompat.IntentBuilder |
addEmailBcc(addresses: Array<String!>)Add an array of email addresses to be used in the "bcc" field of the final Intent. |
ShareCompat.IntentBuilder |
addEmailCc(address: String)Add an email address to be used in the "cc" field of the final Intent. |
ShareCompat.IntentBuilder |
addEmailCc(addresses: Array<String!>)Add an array of email addresses to be used in the "cc" field of the final Intent. |
ShareCompat.IntentBuilder |
addEmailTo(address: String)Add an email address to be used in the "to" field of the final Intent. |
ShareCompat.IntentBuilder |
addEmailTo(addresses: Array<String!>)Add an array of email addresses to be used in the "to" field of the final Intent. |
ShareCompat.IntentBuilder |
Add a stream URI to the data that should be shared. |
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. |
java-static ShareCompat.IntentBuilder |
This function is deprecated. Use the constructor of IntentBuilder |
Intent |
Retrieve the Intent as configured so far by the IntentBuilder. |
ShareCompat.IntentBuilder |
setChooserTitle(resId: @StringRes Int)Set the title that will be used for the activity chooser for this share. |
ShareCompat.IntentBuilder |
setChooserTitle(title: CharSequence?)Set the title that will be used for the activity chooser for this share. |
ShareCompat.IntentBuilder |
setEmailBcc(addresses: Array<String!>?)Set an array of email addresses to BCC on this share. |
ShareCompat.IntentBuilder |
setEmailCc(addresses: Array<String!>?)Set an array of email addresses to CC on this share. |
ShareCompat.IntentBuilder |
setEmailTo(addresses: Array<String!>?)Set an array of email addresses as recipients of this share. |
ShareCompat.IntentBuilder |
setHtmlText(htmlText: String?)Set an HTML string to be sent as part of the share. |
ShareCompat.IntentBuilder |
Set a stream URI to the data that should be shared. |
ShareCompat.IntentBuilder |
setSubject(subject: String?)Set a subject heading for this share; useful for sharing via email. |
ShareCompat.IntentBuilder |
setText(text: CharSequence?)Set the literal text data to be sent as part of the share. |
ShareCompat.IntentBuilder |
Set the type of data being shared |
Unit |
Start a chooser activity for the current share intent. |
Public constructors
IntentBuilder
IntentBuilder(launchingContext: Context)
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.
| Parameters | |
|---|---|
launchingContext: Context |
Context that the share will be launched from |
Public functions
addEmailBcc
fun addEmailBcc(address: String): ShareCompat.IntentBuilder
Add an email address to be used in the "bcc" field of the final Intent.
| Parameters | |
|---|---|
address: String |
Email address to BCC |
| Returns | |
|---|---|
ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
EXTRA_BCC |
addEmailBcc
fun addEmailBcc(addresses: Array<String!>): ShareCompat.IntentBuilder
Add an array of email addresses to be used in the "bcc" field of the final Intent.
| Returns | |
|---|---|
ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
EXTRA_BCC |
addEmailCc
fun addEmailCc(address: String): ShareCompat.IntentBuilder
Add an email address to be used in the "cc" field of the final Intent.
| Parameters | |
|---|---|
address: String |
Email address to CC |
| Returns | |
|---|---|
ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
EXTRA_CC |
addEmailCc
fun addEmailCc(addresses: Array<String!>): ShareCompat.IntentBuilder
Add an array of email addresses to be used in the "cc" field of the final Intent.
| Returns | |
|---|---|
ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
EXTRA_CC |
addEmailTo
fun addEmailTo(address: String): ShareCompat.IntentBuilder
Add an email address to be used in the "to" field of the final Intent.
| Parameters | |
|---|---|
address: String |
Email address to send to |
| Returns | |
|---|---|
ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
EXTRA_EMAIL |
addEmailTo
fun addEmailTo(addresses: Array<String!>): ShareCompat.IntentBuilder
Add an array of email addresses to be used in the "to" field of the final Intent.
| Returns | |
|---|---|
ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
EXTRA_EMAIL |
addStream
fun addStream(streamUri: Uri): ShareCompat.IntentBuilder
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 |
URI of the stream to share |
| Returns | |
|---|---|
ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
EXTRA_STREAM |
|
ACTION_SEND |
|
ACTION_SEND_MULTIPLE |
createChooserIntent
fun createChooserIntent(): 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.
| Returns | |
|---|---|
Intent |
A chooser Intent for the currently configured sharing action |
java-static funfrom(launchingActivity: Activity): ShareCompat.IntentBuilder
Create a new IntentBuilder for launching a sharing action from launchingActivity.
| Parameters | |
|---|---|
launchingActivity: Activity |
Activity that the share will be launched from |
| Returns | |
|---|---|
ShareCompat.IntentBuilder |
a new IntentBuilder instance |
getIntent
fun getIntent(): Intent
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.
| Returns | |
|---|---|
Intent |
The current Intent being configured by this builder |
setChooserTitle
fun setChooserTitle(resId: @StringRes Int): ShareCompat.IntentBuilder
Set the title that will be used for the activity chooser for this share.
| Returns | |
|---|---|
ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
setChooserTitle
fun setChooserTitle(title: CharSequence?): ShareCompat.IntentBuilder
Set the title that will be used for the activity chooser for this share.
| Parameters | |
|---|---|
title: CharSequence? |
Title string |
| Returns | |
|---|---|
ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
setEmailBcc
fun setEmailBcc(addresses: Array<String!>?): ShareCompat.IntentBuilder
Set an array of email addresses to BCC on this share. This replaces all current "BCC" recipients that have been set so far.
| Returns | |
|---|---|
ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
EXTRA_BCC |
setEmailCc
fun setEmailCc(addresses: Array<String!>?): ShareCompat.IntentBuilder
Set an array of email addresses to CC on this share. This replaces all current "CC" recipients that have been set so far.
| Returns | |
|---|---|
ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
EXTRA_CC |
setEmailTo
fun setEmailTo(addresses: Array<String!>?): ShareCompat.IntentBuilder
Set an array of email addresses as recipients of this share. This replaces all current "to" recipients that have been set so far.
| Returns | |
|---|---|
ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
EXTRA_EMAIL |
setHtmlText
fun setHtmlText(htmlText: String?): ShareCompat.IntentBuilder
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 | |
|---|---|
htmlText: String? |
A string containing HTML markup as a richer version of the text provided by EXTRA_TEXT. |
| Returns | |
|---|---|
ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
setText |
setStream
fun setStream(streamUri: Uri?): ShareCompat.IntentBuilder
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? |
URI of the stream to share |
| Returns | |
|---|---|
ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
EXTRA_STREAM |
setSubject
fun setSubject(subject: String?): ShareCompat.IntentBuilder
Set a subject heading for this share; useful for sharing via email.
| Parameters | |
|---|---|
subject: String? |
Subject heading for this share |
| Returns | |
|---|---|
ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
EXTRA_SUBJECT |
setText
fun setText(text: CharSequence?): ShareCompat.IntentBuilder
Set the literal text data to be sent as part of the share. This may be a styled CharSequence.
| Parameters | |
|---|---|
text: CharSequence? |
Text to share |
| Returns | |
|---|---|
ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
EXTRA_TEXT |
setType
fun setType(mimeType: String?): ShareCompat.IntentBuilder
Set the type of data being shared
| Parameters | |
|---|---|
mimeType: String? |
mimetype of the shared data |
| Returns | |
|---|---|
ShareCompat.IntentBuilder |
This IntentBuilder for method chaining |
| See also | |
|---|---|
setType |
startChooser
fun startChooser(): Unit
Start a chooser activity for the current share intent.