public class ShareIntent extends BaseIntent<ShareIntent>
BaseIntent builder implementation providing API for building and starting of intents
targeting a content sharing related applications.
This intent builder requires a mime type of the sharing content to be specified via mimeType(String).
You may use one of predefined mime types from MimeType class. The content to be shared
may be specified as string based content via content(CharSequence) or if there is to be
shared a content that is represented by an Uri, such Uri may be specified via uri(Uri)
or uris(List).
| Constructor and Description |
|---|
ShareIntent() |
| Modifier and Type | Method and Description |
|---|---|
CharSequence |
content()
Returns the text that will be used as content for the sharing intent.
|
ShareIntent |
content(CharSequence text)
Sets a content for the sharing intent.
|
protected void |
ensureCanBuildOrThrow()
Called to ensure that this builder can build its Intent from its current data.
|
String |
mimeType()
Returns the MIME type of the content to be shared.
|
ShareIntent |
mimeType(String type)
|
protected android.content.Intent |
onBuild(android.content.Context context)
Invoked from
BaseIntent.build(Context) after BaseIntent.ensureCanBuildOrThrow() to build intent
specific for this intent builder from the current data. |
protected boolean |
onStartWith(IntentStarter starter,
android.content.Intent intent)
Invoked whenever
BaseIntent.startWith(IntentStarter) is called and there is an activity available
that can handle the given intent that has been created via BaseIntent.build(Context). |
CharSequence |
title()
Returns the title text that will be used as title for sharing intent.
|
ShareIntent |
title(CharSequence title)
Sets a title for sharing intent.
|
android.net.Uri |
uri()
Returns the Uri to content to be shared.
|
ShareIntent |
uri(android.net.Uri uri)
Sets an Uri to content that should be shared.
|
List<android.net.Uri> |
uris()
Returns the list of Uris to content to be shared.
|
ShareIntent |
uris(List<android.net.Uri> uris)
Sets a list of Uris to content that should be shared.
|
ShareIntent |
uris(android.net.Uri... uris)
Same as
uris(List) for variable array of Uris. |
activityNotFoundMessage, activityNotFoundMessage, build, cannotBuildIntentException, dialogTitle, dialogTitle, enterTransition, enterTransition, exitTransition, exitTransition, isActivityForIntentAvailable, notifyActivityNotFound, startWith, transitionspublic ShareIntent content(CharSequence text)
text - The desired content text. May be null to clear the current one.content()public CharSequence content()
content(CharSequence)public ShareIntent uri(android.net.Uri uri)
uri - The desired content Uri. May be null to clear the current one.uri()public android.net.Uri uri()
null if not specified yet.uri(Uri)public ShareIntent uris(android.net.Uri... uris)
uris(List) for variable array of Uris.uris - The desired array of content uris.uris()public ShareIntent uris(List<android.net.Uri> uris)
uris - The desired list of content uris. May be null to clear the current one.uris(Uri...),
uris()public List<android.net.Uri> uris()
Collections.EMPTY_LIST if there were no Uris specified
yet.uris(Uri...),
uris(List)public ShareIntent mimeType(String type)
content(CharSequence) or uri(Uri)
or uris(List).
Default value: MimeType.TEXT
type - The desired content MIME type.mimeType()public String mimeType()
MimeType class.mimeType(String)public ShareIntent title(CharSequence title)
title - The desired title text. May be null to clear the current one.title()public CharSequence title()
title(CharSequence)protected void ensureCanBuildOrThrow()
BaseIntent
If there are some required data missing/not specified, an exception indicating such state
should be thrown. The default exception may be created via BaseIntent.cannotBuildIntentException(String).
ensureCanBuildOrThrow in class BaseIntent<ShareIntent>protected android.content.Intent onBuild(android.content.Context context)
BaseIntentBaseIntent.build(Context) after BaseIntent.ensureCanBuildOrThrow() to build intent
specific for this intent builder from the current data.onBuild in class BaseIntent<ShareIntent>context - Context obtained from the IntentStarter.protected boolean onStartWith(IntentStarter starter, android.content.Intent intent)
BaseIntentBaseIntent.startWith(IntentStarter) is called and there is an activity available
that can handle the given intent that has been created via BaseIntent.build(Context).
This implementation always returns true.
onStartWith in class BaseIntent<ShareIntent>starter - The starter with which to start the intent.intent - The intent instance created by this intent builder.True to indicate that the intent has been started, false otherwise.