# ActivityOptionsCompat

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

*** ** * ** ***


```
public class ActivityOptionsCompat
```

<br />

*** ** * ** ***

Helper for accessing features in `https://developer.android.com/reference/android/app/ActivityOptions.html` in a backwards compatible fashion.

## Summary

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#EXTRA_USAGE_TIME_REPORT() = "android.activity.usage_time"` A long in the extras delivered by `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#requestUsageTimeReport(android.app.PendingIntent)` that contains the total time (in ms) the user spent in the app flow. |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#EXTRA_USAGE_TIME_REPORT_PACKAGES() = "android.usage_time_packages"` A Bundle in the extras delivered by `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#requestUsageTimeReport(android.app.PendingIntent)` that contains detailed information about the time spent in each package associated with the app; each key is a package name, whose value is a long containing the time (in ms). |

| ### Protected constructors |
|---|
| `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#ActivityOptionsCompat()()` |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/graphics/Rect.html` | `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#getLaunchBounds()()` Returns the bounds that should be used to launch the activity. |
| `int` | `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#getLaunchDisplayId()()` Gets the id of the display where activity should be launched. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat` | `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#makeBasic()()` Create a basic ActivityOptions that has no special animation associated with it. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat` | `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#makeClipRevealAnimation(android.view.View,int,int,int,int)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html source, int startX, int startY, int width, int height )` Create an ActivityOptions specifying an animation where the new activity is revealed from a small originating area of the screen to its final full representation. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat` | `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#makeCustomAnimation(android.content.Context,int,int)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, int enterResId, int exitResId )` Create an ActivityOptions specifying a custom animation to run when the activity is displayed. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat` | `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#makeScaleUpAnimation(android.view.View,int,int,int,int)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html source, int startX, int startY, int startWidth, int startHeight )` Create an ActivityOptions specifying an animation where the new activity is scaled from a small originating area of the screen to its final full representation. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat` | `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#makeSceneTransitionAnimation(android.app.Activity,androidx.core.util.Pair<android.view.View,java.lang.String>...)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/Activity.html activity, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html Pair[] sharedElements )` Create an ActivityOptions to transition between Activities using cross-Activity scene animations. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat` | `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#makeSceneTransitionAnimation(android.app.Activity,android.view.View,java.lang.String)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/Activity.html activity, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html sharedElement, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html sharedElementName )` Create an ActivityOptions to transition between Activities using cross-Activity scene animations. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat` | `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#makeTaskLaunchBehind()()` If set along with Intent.FLAG_ACTIVITY_NEW_DOCUMENT then the task being launched will not be presented to the user but will instead be only available through the recents task list. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat` | `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#makeThumbnailScaleUpAnimation(android.view.View,android.graphics.Bitmap,int,int)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html source, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Bitmap.html thumbnail, int startX, int startY )` Create an ActivityOptions specifying an animation where a thumbnail is scaled from a given position to the new activity window that is being started. |
| `void` | `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#requestUsageTimeReport(android.app.PendingIntent)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/PendingIntent.html receiver)` Ask the the system track that time the user spends in the app being launched, and report it back once done. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat` | `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#setLaunchBounds(android.graphics.Rect)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/graphics/Rect.html screenSpacePixelRect)` Sets the bounds (window size) that the activity should be launched in. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat` | `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#setLaunchDisplayId(int)(int launchDisplayId)` Sets the id of the display where the activity should be launched. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat` | `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#setPendingIntentBackgroundActivityStartMode(int)(int state)` Sets the mode for allowing or denying the senders privileges to start background activities to the PendingIntent. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat` | `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#setShareIdentityEnabled(boolean)(boolean shareIdentity)` Sets whether the identity of the launching app should be shared with the activity. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Bundle.html` | `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#toBundle()()` Returns the created options as a Bundle, which can be passed to `https://developer.android.com/reference/androidx/core/content/ContextCompat#startActivity(android.content.Context,android.content.Intent,android.os.Bundle)`. |
| `void` | `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#update(androidx.core.app.ActivityOptionsCompat)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat otherOptions)` Update the current values in this ActivityOptions from those supplied in otherOptions. |

## Constants

### EXTRA_USAGE_TIME_REPORT

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

```
public static final String EXTRA_USAGE_TIME_REPORT = "android.activity.usage_time"
```

A long in the extras delivered by `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#requestUsageTimeReport(android.app.PendingIntent)` that contains the total time (in ms) the user spent in the app flow.

### EXTRA_USAGE_TIME_REPORT_PACKAGES

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

```
public static final String EXTRA_USAGE_TIME_REPORT_PACKAGES = "android.usage_time_packages"
```

A Bundle in the extras delivered by `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#requestUsageTimeReport(android.app.PendingIntent)` that contains detailed information about the time spent in each package associated with the app; each key is a package name, whose value is a long containing the time (in ms).

## Protected constructors

### ActivityOptionsCompat

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

```
protected ActivityOptionsCompat()
```

## Public methods

### getLaunchBounds

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

```
public @Nullable Rect getLaunchBounds()
```

Returns the bounds that should be used to launch the activity.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/graphics/Rect.html` | Bounds used to launch the activity. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#setLaunchBounds(android.graphics.Rect)` |   |

### getLaunchDisplayId

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

```
public int getLaunchDisplayId()
```

Gets the id of the display where activity should be launched.

On API 25 and below, this method always returns `https://developer.android.com/reference/android/view/Display.html#INVALID_DISPLAY`.

| Returns |
|---|---|
| `int` | The id of the display where activity should be launched, `https://developer.android.com/reference/android/view/Display.html#INVALID_DISPLAY` if not set. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#setLaunchDisplayId(int)` |   |

### makeBasic

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

```
public static @NonNull ActivityOptionsCompat makeBasic()
```

Create a basic ActivityOptions that has no special animation associated with it. Other options can still be set.

### makeClipRevealAnimation

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

```
public static @NonNull ActivityOptionsCompat makeClipRevealAnimation(
    @NonNull View source,
    int startX,
    int startY,
    int width,
    int height
)
```

Create an ActivityOptions specifying an animation where the new activity is revealed from a small originating area of the screen to its final full representation.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html source` | The View that the new activity is animating from. This defines the coordinate space for <var translate="no">startX</var> and <var translate="no">startY</var>. |
| `int startX` | The x starting location of the new activity, relative to <var translate="no">source</var>. |
| `int startY` | The y starting location of the activity, relative to <var translate="no">source</var>. |
| `int width` | The initial width of the new activity. |
| `int height` | The initial height of the new activity. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat` | Returns a new ActivityOptions object that you can use to supply these options as the options Bundle when starting an activity. |

### makeCustomAnimation

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

```
public static @NonNull ActivityOptionsCompat makeCustomAnimation(
    @NonNull Context context,
    int enterResId,
    int exitResId
)
```

Create an ActivityOptions specifying a custom animation to run when the activity is displayed.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context` | Who is defining this. This is the application that the animation resources will be loaded from. |
| `int enterResId` | A resource ID of the animation resource to use for the incoming activity. Use 0 for no animation. |
| `int exitResId` | A resource ID of the animation resource to use for the outgoing activity. Use 0 for no animation. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat` | Returns a new ActivityOptions object that you can use to supply these options as the options Bundle when starting an activity. |

### makeScaleUpAnimation

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

```
public static @NonNull ActivityOptionsCompat makeScaleUpAnimation(
    @NonNull View source,
    int startX,
    int startY,
    int startWidth,
    int startHeight
)
```

Create an ActivityOptions specifying an animation where the new activity is scaled from a small originating area of the screen to its final full representation.
If the Intent this is being used with has not set its `https://developer.android.com/reference/android/content/Intent.html#setSourceBounds(android.graphics.Rect)`, those bounds will be filled in for you based on the initial bounds passed in here.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html source` | The View that the new activity is animating from. This defines the coordinate space for startX and startY. |
| `int startX` | The x starting location of the new activity, relative to source. |
| `int startY` | The y starting location of the activity, relative to source. |
| `int startWidth` | The initial width of the new activity. |
| `int startHeight` | The initial height of the new activity. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat` | Returns a new ActivityOptions object that you can use to supply these options as the options Bundle when starting an activity. |

### makeSceneTransitionAnimation

```
public static @NonNull ActivityOptionsCompat makeSceneTransitionAnimation(
    @NonNull Activity activity,
    @Nullable Pair[] sharedElements
)
```

Create an ActivityOptions to transition between Activities using cross-Activity scene animations. This method carries the position of multiple shared elements to the started Activity. The position of the first element in sharedElements will be used as the epicenter for the exit Transition. The position of the associated shared element in the launched Activity will be the epicenter of its entering Transition.

This requires `https://developer.android.com/reference/android/view/Window.html#FEATURE_CONTENT_TRANSITIONS` to be enabled on the calling Activity to cause an exit transition. The same must be in the called Activity to get an entering transition.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/Activity.html activity` | The Activity whose window contains the shared elements. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html Pair[] sharedElements` | The names of the shared elements to transfer to the called Activity and their associated Views. The Views must each have a unique shared element name. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat` | Returns a new ActivityOptions object that you can use to supply these options as the options Bundle when starting an activity. |

### makeSceneTransitionAnimation

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

```
public static @NonNull ActivityOptionsCompat makeSceneTransitionAnimation(
    @NonNull Activity activity,
    @NonNull View sharedElement,
    @NonNull String sharedElementName
)
```

Create an ActivityOptions to transition between Activities using cross-Activity scene animations. This method carries the position of one shared element to the started Activity. The position of `sharedElement` will be used as the epicenter for the exit Transition. The position of the shared element in the launched Activity will be the epicenter of its entering Transition.

This requires `https://developer.android.com/reference/android/view/Window.html#FEATURE_CONTENT_TRANSITIONS` to be enabled on the calling Activity to cause an exit transition. The same must be in the called Activity to get an entering transition.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/Activity.html activity` | The Activity whose window contains the shared elements. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html sharedElement` | The View to transition to the started Activity. sharedElement must have a non-null sharedElementName. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html sharedElementName` | The shared element name as used in the target Activity. This may be null if it has the same name as sharedElement. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat` | Returns a new ActivityOptions object that you can use to supply these options as the options Bundle when starting an activity. |

### makeTaskLaunchBehind

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

```
public static @NonNull ActivityOptionsCompat makeTaskLaunchBehind()
```

If set along with Intent.FLAG_ACTIVITY_NEW_DOCUMENT then the task being launched will not be presented to the user but will instead be only available through the recents task list. In addition, the new task wil be affiliated with the launching activity's task. Affiliated tasks are grouped together in the recents task list.

This behavior is not supported for activities with `https://developer.android.com/reference/android/R.attr.html#launchMode` values of `singleInstance` or `singleTask`.

### makeThumbnailScaleUpAnimation

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

```
public static @NonNull ActivityOptionsCompat makeThumbnailScaleUpAnimation(
    @NonNull View source,
    @NonNull Bitmap thumbnail,
    int startX,
    int startY
)
```

Create an ActivityOptions specifying an animation where a thumbnail is scaled from a given position to the new activity window that is being started.
If the Intent this is being used with has not set its `https://developer.android.com/reference/android/content/Intent.html#setSourceBounds(android.graphics.Rect)`, those bounds will be filled in for you based on the initial thumbnail location and size provided here.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html source` | The View that this thumbnail is animating from. This defines the coordinate space for startX and startY. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Bitmap.html thumbnail` | The bitmap that will be shown as the initial thumbnail of the animation. |
| `int startX` | The x starting location of the bitmap, relative to source. |
| `int startY` | The y starting location of the bitmap, relative to source. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat` | Returns a new ActivityOptions object that you can use to supply these options as the options Bundle when starting an activity. |

### requestUsageTimeReport

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

```
public void requestUsageTimeReport(@NonNull PendingIntent receiver)
```

Ask the the system track that time the user spends in the app being launched, and report it back once done. The report will be sent to the given receiver, with the extras `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#EXTRA_USAGE_TIME_REPORT()` and `https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat#EXTRA_USAGE_TIME_REPORT_PACKAGES()` filled in.

The time interval tracked is from launching this activity until the user leaves that activity's flow. They are considered to stay in the flow as long as new activities are being launched or returned to from the original flow, even if this crosses package or task boundaries. For example, if the originator starts an activity to view an image, and while there the user selects to share, which launches their email app in a new task, and they complete the share, the time during that entire operation will be included until they finally hit back from the original image viewer activity.

The user is considered to complete a flow once they switch to another activity that is not part of the tracked flow. This may happen, for example, by using the notification shade, launcher, or recents to launch or switch to another app. Simply going in to these navigation elements does not break the flow (although the launcher and recents stops time tracking of the session); it is the act of going somewhere else that completes the tracking.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/PendingIntent.html receiver` | A broadcast receiver that will receive the report. |

### setLaunchBounds

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

```
public @NonNull ActivityOptionsCompat setLaunchBounds(@Nullable Rect screenSpacePixelRect)
```

Sets the bounds (window size) that the activity should be launched in. Rect position should be provided in pixels and in screen coordinates. Set to null explicitly for fullscreen.

**NOTE: This value is ignored on devices that don't have `https://developer.android.com/reference/android/content/pm/PackageManager.html#FEATURE_FREEFORM_WINDOW_MANAGEMENT` or `https://developer.android.com/reference/android/content/pm/PackageManager.html#FEATURE_PICTURE_IN_PICTURE` enabled.**

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/graphics/Rect.html screenSpacePixelRect` | Launch bounds to use for the activity or null for fullscreen. |

### setLaunchDisplayId

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

```
public @NonNull ActivityOptionsCompat setLaunchDisplayId(int launchDisplayId)
```

Sets the id of the display where the activity should be launched. An app can launch activities on public displays or displays where the app already has activities. Otherwise, trying to launch on a private display or providing an invalid display id will result in an exception.

Setting launch display id will be ignored on devices that don't have `https://developer.android.com/reference/android/content/pm/PackageManager.html#FEATURE_ACTIVITIES_ON_SECONDARY_DISPLAYS`.

On API 25 and below, calling this method has no effect.

| Parameters |
|---|---|
| `int launchDisplayId` | The id of the display where the activity should be launched. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat` | `this``https://developer.android.com/reference/android/app/ActivityOptions.html` instance. |

### setPendingIntentBackgroundActivityStartMode

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

```
public @NonNull ActivityOptionsCompat setPendingIntentBackgroundActivityStartMode(int state)
```

Sets the mode for allowing or denying the senders privileges to start background activities to the PendingIntent.
This is typically used in when executing `https://developer.android.com/reference/android/app/PendingIntent.html#send(android.content.Context, int, android.content.Intent)` or similar methods. A privileged sender of a PendingIntent should only grant `https://developer.android.com/reference/android/app/ActivityOptions.html#MODE_BACKGROUND_ACTIVITY_START_ALLOWED` if the PendingIntent is from a trusted source and/or executed on behalf the user.

### setShareIdentityEnabled

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

```
public @NonNull ActivityOptionsCompat setShareIdentityEnabled(boolean shareIdentity)
```

Sets whether the identity of the launching app should be shared with the activity.

Use this option when starting an activity that needs to know the identity of the launching app; with this set to `true`, the activity will have access to the launching app's package name and uid.

Defaults to `false` if not set. This is a no-op before U.

Note, even if the launching app does not explicitly enable sharing of its identity, if the activity is started with `Activity#startActivityForResult`, then `https://developer.android.com/reference/android/app/Activity.html#getCallingPackage()` will still return the launching app's package name to allow validation of the result's recipient. Also, an activity running within a package signed by the same key used to sign the platform (some system apps such as Settings will be signed with the platform's key) will have access to the launching app's identity.

| Parameters |
|---|---|
| `boolean shareIdentity` | whether the launching app's identity should be shared with the activity |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/ActivityOptionsCompat` | `this``https://developer.android.com/reference/android/app/ActivityOptions.html` instance. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/app/Activity.html#getLaunchedFromPackage()` |   |
| `https://developer.android.com/reference/android/app/Activity.html#getLaunchedFromUid()` |   |

### toBundle

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

```
public @Nullable Bundle toBundle()
```

Returns the created options as a Bundle, which can be passed to `https://developer.android.com/reference/androidx/core/content/ContextCompat#startActivity(android.content.Context,android.content.Intent,android.os.Bundle)`. Note that the returned Bundle is still owned by the ActivityOptions object; you must not modify it, but can supply it to the startActivity methods that take an options Bundle.

### update

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

```
public void update(@NonNull ActivityOptionsCompat otherOptions)
```

Update the current values in this ActivityOptions from those supplied in otherOptions. Any values defined in otherOptions replace those in the base options.