# ShareCompat.IntentReader

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/app/ShareCompat.java+class:androidx.core.app.ShareCompat.IntentReader) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***


```
public class ShareCompat.IntentReader
```

<br />

*** ** * ** ***

IntentReader is a helper for reading the data contained within a sharing (ACTION_SEND) Intent. It provides methods to parse standard elements included with a share in addition to extra metadata about the app that shared the content.

Social sharing apps are encouraged to provide attribution for the app that shared the content. IntentReader offers access to the application label, calling activity info, and application icon of the app that shared the content. This data may have been provided voluntarily by the calling app and should always be displayed to the user before submission for manual verification. The user should be offered the option to omit this information from shared posts if desired.

Activities that intend to receive sharing intents should configure an intent-filter to accept `https://developer.android.com/reference/android/content/Intent.html#ACTION_SEND` intents ("android.intent.action.SEND") and optionally accept `https://developer.android.com/reference/android/content/Intent.html#ACTION_SEND_MULTIPLE` ("android.intent.action.SEND_MULTIPLE") if the activity is equipped to handle multiple data streams.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader#IntentReader(android.app.Activity)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/Activity.html activity)` Create an IntentReader for parsing and interpreting the sharing intent used to start the given activity. |
| `https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader#IntentReader(android.content.Context,android.content.Intent)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Intent.html intent)` Create an IntentReader for parsing and interpreting the given sharing intent. |

| ### Public methods |
|---|---|
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader` | `[from](https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader#from(android.app.Activity))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/Activity.html activity)` **This method is deprecated.** Use the constructor of IntentReader instead <br /> |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/content/ComponentName.html` | `https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader#getCallingActivity()()` Get the `https://developer.android.com/reference/android/content/ComponentName.html` of the Activity that invoked this sharing intent. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/graphics/drawable/Drawable.html` | `https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader#getCallingActivityIcon()()` Get the icon of the calling activity as a Drawable if data about the calling activity is available. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/graphics/drawable/Drawable.html` | `https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader#getCallingApplicationIcon()()` Get the icon of the calling application as a Drawable if data about the calling package is available. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/CharSequence.html` | `https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader#getCallingApplicationLabel()()` Get the human-readable label (title) of the calling application if data about the calling package is available. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader#getCallingPackage()()` Get the name of the package that invoked this sharing intent. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html String[]` | `https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader#getEmailBcc()()` Get an array of Strings, each an email address to BCC on this share. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html String[]` | `https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader#getEmailCc()()` Get an array of Strings, each an email address to CC on this share. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html String[]` | `https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader#getEmailTo()()` Get an array of Strings, each an email address to share to. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader#getHtmlText()()` Get the styled HTML text shared with the target activity. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/net/Uri.html` | `https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader#getStream()()` Get a URI referring to a data stream shared with the target activity. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/net/Uri.html` | `https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader#getStream(int)(int index)` Get the URI of a stream item shared with the target activity. |
| `int` | `https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader#getStreamCount()()` Return the number of stream items shared. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader#getSubject()()` Get a subject heading for this share; useful when sharing via email. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/CharSequence.html` | `https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader#getText()()` Get the literal text shared with the target activity. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader#getType()()` Get the mimetype of the data shared to this activity. |
| `boolean` | `https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader#isMultipleShare()()` Returns true if the activity this reader was obtained for was started with an `https://developer.android.com/reference/android/content/Intent.html#ACTION_SEND_MULTIPLE` intent. |
| `boolean` | `https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader#isShareIntent()()` Returns true if the activity this reader was obtained for was started with an `https://developer.android.com/reference/android/content/Intent.html#ACTION_SEND` or `https://developer.android.com/reference/android/content/Intent.html#ACTION_SEND_MULTIPLE` sharing Intent. |
| `boolean` | `https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader#isSingleShare()()` Returns true if the activity this reader was obtained for was started with an `https://developer.android.com/reference/android/content/Intent.html#ACTION_SEND` intent and contains a single shared item. |

## Public constructors

### IntentReader

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public IntentReader(@NonNull Activity activity)
```

Create an IntentReader for parsing and interpreting the sharing intent used to start the given activity.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/Activity.html activity` | Activity that was started to share content |

### IntentReader

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public IntentReader(@NonNull Context context, @NonNull Intent intent)
```

Create an IntentReader for parsing and interpreting the given sharing intent.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context` | Context that was started to share content |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Intent.html intent` | Intent that was used to start the context |

## Public methods

### from

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public static @NonNull ShareCompat.IntentReader [from](https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader#from(android.app.Activity))(@NonNull Activity activity)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use the constructor of IntentReader instead

Get an IntentReader for parsing and interpreting the sharing intent used to start the given activity.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/Activity.html activity` | Activity that was started to share content |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader` | IntentReader for parsing sharing data |

### getCallingActivity

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public @Nullable ComponentName getCallingActivity()
```

Get the `https://developer.android.com/reference/android/content/ComponentName.html` of the Activity that invoked this sharing intent. If the target sharing activity was not started for a result, IntentBuilder will read this from extra metadata placed in the intent by ShareBuilder.

*Note:* This data may have been provided voluntarily by the calling application. As such it should not be trusted for accuracy in the context of security or verification.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/content/ComponentName.html` | ComponentName of the calling Activity or null if unknown |

| See also |
|---|---|
| `https://developer.android.com/reference/android/app/Activity.html#getCallingActivity()` |   |
| `https://developer.android.com/reference/androidx/core/app/ShareCompat#EXTRA_CALLING_ACTIVITY()` |   |
| `https://developer.android.com/reference/androidx/core/app/ShareCompat#EXTRA_CALLING_ACTIVITY_INTEROP()` |   |

### getCallingActivityIcon

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public @Nullable Drawable getCallingActivityIcon()
```

Get the icon of the calling activity as a Drawable if data about the calling activity is available.

*Note:* This data may have been provided voluntarily by the calling application. As such it should not be trusted for accuracy in the context of security or verification.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/graphics/drawable/Drawable.html` | The calling Activity's icon or null if unknown |

### getCallingApplicationIcon

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public @Nullable Drawable getCallingApplicationIcon()
```

Get the icon of the calling application as a Drawable if data about the calling package is available.

*Note:* This data may have been provided voluntarily by the calling application. As such it should not be trusted for accuracy in the context of security or verification.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/graphics/drawable/Drawable.html` | The calling application's icon or null if unknown |

### getCallingApplicationLabel

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public @Nullable CharSequence getCallingApplicationLabel()
```

Get the human-readable label (title) of the calling application if data about the calling package is available.

*Note:* This data may have been provided voluntarily by the calling application. As such it should not be trusted for accuracy in the context of security or verification.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/CharSequence.html` | The calling application's label or null if unknown |

### getCallingPackage

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public @Nullable String getCallingPackage()
```

Get the name of the package that invoked this sharing intent. If the activity was not started for a result, IntentBuilder will read this from extra metadata placed in the Intent by ShareBuilder.

*Note:* This data may have been provided voluntarily by the calling application. As such it should not be trusted for accuracy in the context of security or verification.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | Name of the package that started this activity or null if unknown |

| See also |
|---|---|
| `https://developer.android.com/reference/android/app/Activity.html#getCallingPackage()` |   |
| `https://developer.android.com/reference/androidx/core/app/ShareCompat#EXTRA_CALLING_PACKAGE()` |   |
| `https://developer.android.com/reference/androidx/core/app/ShareCompat#EXTRA_CALLING_PACKAGE_INTEROP()` |   |

### getEmailBcc

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public @Nullable String[] getEmailBcc()
```

Get an array of Strings, each an email address to BCC on this share.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html String[]` | An array of email addresses or null if none were supplied. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/content/Intent.html#EXTRA_BCC` |   |

### getEmailCc

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public @Nullable String[] getEmailCc()
```

Get an array of Strings, each an email address to CC on this share.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html String[]` | An array of email addresses or null if none were supplied. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/content/Intent.html#EXTRA_CC` |   |

### getEmailTo

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public @Nullable String[] getEmailTo()
```

Get an array of Strings, each an email address to share to.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html String[]` | An array of email addresses or null if none were supplied. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/content/Intent.html#EXTRA_EMAIL` |   |

### getHtmlText

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public @Nullable String getHtmlText()
```

Get the styled HTML text shared with the target activity. If no HTML text was supplied but `https://developer.android.com/reference/android/content/Intent.html#EXTRA_TEXT` contained styled text, it will be converted to HTML if possible and returned. If the text provided by `https://developer.android.com/reference/android/content/Intent.html#EXTRA_TEXT` was not styled text, it will be escaped by `https://developer.android.com/reference/android/text/Html.html#escapeHtml(java.lang.CharSequence)` and returned. If no text was provided at all, this method will return null.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | Styled text provided by the sender as HTML. |

### getStream

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public @Nullable Uri getStream()
```

Get a URI referring to a data stream shared with the target activity.

This call will fail if the share intent contains multiple stream items. If `https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader#isMultipleShare()` returns true the application should use `https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader#getStream(int)` and `https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader#getStreamCount()` to retrieve the included stream items.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/net/Uri.html` | A URI referring to a data stream to be shared or null if one was not supplied |

| See also |
|---|---|
| `https://developer.android.com/reference/android/content/Intent.html#EXTRA_STREAM` |   |

### getStream

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public @Nullable Uri getStream(int index)
```

Get the URI of a stream item shared with the target activity. Index should be in the range \[0-getStreamCount()).

| Parameters |
|---|---|
| `int index` | Index of text item to retrieve |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/net/Uri.html` | Requested stream item URI |

| See also |
|---|---|
| `https://developer.android.com/reference/android/content/Intent.html#EXTRA_STREAM` |   |
| `https://developer.android.com/reference/android/content/Intent.html#ACTION_SEND_MULTIPLE` |   |

### getStreamCount

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public int getStreamCount()
```

Return the number of stream items shared. The return value will be 0 or 1 if this was an `https://developer.android.com/reference/android/content/Intent.html#ACTION_SEND` intent, or 0 or more if it was an `https://developer.android.com/reference/android/content/Intent.html#ACTION_SEND_MULTIPLE` intent.

| Returns |
|---|---|
| `int` | Count of text items contained within the Intent |

### getSubject

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public @Nullable String getSubject()
```

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

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | The subject heading for this share or null if one was not supplied. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/content/Intent.html#EXTRA_SUBJECT` |   |

### getText

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public @Nullable CharSequence getText()
```

Get the literal text shared with the target activity.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/CharSequence.html` | Literal shared text or null if none was supplied |

| See also |
|---|---|
| `https://developer.android.com/reference/android/content/Intent.html#EXTRA_TEXT` |   |

### getType

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public @Nullable String getType()
```

Get the mimetype of the data shared to this activity.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | mimetype of the shared data |

| See also |
|---|---|
| `https://developer.android.com/reference/android/content/Intent.html#getType()` |   |

### isMultipleShare

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public boolean isMultipleShare()
```

Returns true if the activity this reader was obtained for was started with an `https://developer.android.com/reference/android/content/Intent.html#ACTION_SEND_MULTIPLE` intent. The Intent may contain more than one stream item.

| Returns |
|---|---|
| `boolean` | true if the activity was started with an ACTION_SEND_MULTIPLE intent |

### isShareIntent

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public boolean isShareIntent()
```

Returns true if the activity this reader was obtained for was started with an `https://developer.android.com/reference/android/content/Intent.html#ACTION_SEND` or `https://developer.android.com/reference/android/content/Intent.html#ACTION_SEND_MULTIPLE` sharing Intent.

| Returns |
|---|---|
| `boolean` | true if the activity was started with an ACTION_SEND or ACTION_SEND_MULTIPLE Intent |

### isSingleShare

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public boolean isSingleShare()
```

Returns true if the activity this reader was obtained for was started with an `https://developer.android.com/reference/android/content/Intent.html#ACTION_SEND` intent and contains a single shared item. The shared content should be obtained using either the `https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader#getText()` or `https://developer.android.com/reference/androidx/core/app/ShareCompat.IntentReader#getStream()` methods depending on the type of content shared.

| Returns |
|---|---|
| `boolean` | true if the activity was started with an ACTION_SEND intent |