# PendingIntentCompat

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

*** ** * ** ***


```
public final class PendingIntentCompat
```

<br />

*** ** * ** ***

Helper for accessing features in `https://developer.android.com/reference/android/app/PendingIntent.html`.

## Summary

| ### Public methods |
|---|---|
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/PendingIntent.html` | `https://developer.android.com/reference/androidx/core/app/PendingIntentCompat#getActivities(android.content.Context,int,android.content.Intent[],int,boolean)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, int requestCode, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html Intent[] intents, int flags, boolean isMutable )` Retrieves a `https://developer.android.com/reference/android/app/PendingIntent.html` with mandatory mutability flag set on supported platform versions. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/PendingIntent.html` | `https://developer.android.com/reference/androidx/core/app/PendingIntentCompat#getActivities(android.content.Context,int,android.content.Intent[],int,android.os.Bundle,boolean)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, int requestCode, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html Intent[] intents, int flags, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Bundle.html options, boolean isMutable )` Retrieves a `https://developer.android.com/reference/android/app/PendingIntent.html` with mandatory mutability flag set on supported platform versions. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/app/PendingIntent.html` | `https://developer.android.com/reference/androidx/core/app/PendingIntentCompat#getActivity(android.content.Context,int,android.content.Intent,int,boolean)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, int requestCode, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Intent.html intent, int flags, boolean isMutable )` Retrieves a `https://developer.android.com/reference/android/app/PendingIntent.html` with mandatory mutability flag set on supported platform versions. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/app/PendingIntent.html` | `https://developer.android.com/reference/androidx/core/app/PendingIntentCompat#getActivity(android.content.Context,int,android.content.Intent,int,android.os.Bundle,boolean)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, int requestCode, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Intent.html intent, int flags, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Bundle.html options, boolean isMutable )` Retrieves a `https://developer.android.com/reference/android/app/PendingIntent.html` with mandatory mutability flag set on supported platform versions. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/app/PendingIntent.html` | `https://developer.android.com/reference/androidx/core/app/PendingIntentCompat#getBroadcast(android.content.Context,int,android.content.Intent,int,boolean)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, int requestCode, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Intent.html intent, int flags, boolean isMutable )` Retrieves a `https://developer.android.com/reference/android/app/PendingIntent.html` with mandatory mutability flag set on supported platform versions. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/PendingIntent.html` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/androidx/core/app/PendingIntentCompat#getForegroundService(android.content.Context,int,android.content.Intent,int,boolean)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, int requestCode, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Intent.html intent, int flags, boolean isMutable )` Retrieves a `https://developer.android.com/reference/android/app/PendingIntent.html` with mandatory mutability flag set on supported platform versions. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/app/PendingIntent.html` | `https://developer.android.com/reference/androidx/core/app/PendingIntentCompat#getService(android.content.Context,int,android.content.Intent,int,boolean)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, int requestCode, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Intent.html intent, int flags, boolean isMutable )` Retrieves a `https://developer.android.com/reference/android/app/PendingIntent.html` with mandatory mutability flag set on supported platform versions. |
| `static void` | `https://developer.android.com/reference/androidx/core/app/PendingIntentCompat#send(android.app.PendingIntent,int,android.app.PendingIntent.OnFinished,android.os.Handler)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/PendingIntent.html pendingIntent, int code, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/app/PendingIntent.OnFinished.html onFinished, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Handler.html handler )` `https://developer.android.com/reference/android/app/PendingIntent.html#send()` variants that support `https://developer.android.com/reference/android/app/PendingIntent.OnFinished.html` callbacks have a bug on many API levels that the callback may be invoked even if the PendingIntent was never sent (ie, such as if the PendingIntent was canceled, and the send() invocation threw a `https://developer.android.com/reference/android/app/PendingIntent.CanceledException.html`). |
| `static void` | `https://developer.android.com/reference/androidx/core/app/PendingIntentCompat#send(android.app.PendingIntent,android.content.Context,int,android.content.Intent,android.app.PendingIntent.OnFinished,android.os.Handler)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/PendingIntent.html pendingIntent, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, int code, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Intent.html intent, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/app/PendingIntent.OnFinished.html onFinished, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Handler.html handler )` `https://developer.android.com/reference/android/app/PendingIntent.html#send()` variants that support `https://developer.android.com/reference/android/app/PendingIntent.OnFinished.html` callbacks have a bug on many API levels that the callback may be invoked even if the PendingIntent was never sent (ie, such as if the PendingIntent was canceled, and the send() invocation threw a `https://developer.android.com/reference/android/app/PendingIntent.CanceledException.html`). |
| `static void` | `https://developer.android.com/reference/androidx/core/app/PendingIntentCompat#send(android.app.PendingIntent,android.content.Context,int,android.content.Intent,android.app.PendingIntent.OnFinished,android.os.Handler,java.lang.String,android.os.Bundle)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/PendingIntent.html pendingIntent, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, int code, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Intent.html intent, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/app/PendingIntent.OnFinished.html onFinished, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Handler.html handler, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html requiredPermissions, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Bundle.html options )` `https://developer.android.com/reference/android/app/PendingIntent.html#send()` variants that support `https://developer.android.com/reference/android/app/PendingIntent.OnFinished.html` callbacks have a bug on many API levels that the callback may be invoked even if the PendingIntent was never sent (ie, such as if the PendingIntent was canceled, and the send() invocation threw a `https://developer.android.com/reference/android/app/PendingIntent.CanceledException.html`). |

## Public methods

### getActivities

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

```
public static @NonNull PendingIntent getActivities(
    @NonNull Context context,
    int requestCode,
    @NonNull Intent[] intents,
    int flags,
    boolean isMutable
)
```

Retrieves a `https://developer.android.com/reference/android/app/PendingIntent.html` with mandatory mutability flag set on supported platform versions. The caller provides the flag as combination of all the other values except mutability flag. This method combines mutability flag when necessary. See `https://developer.android.com/reference/android/app/PendingIntent.html#getActivities(android.content.Context, int, android.content.Intent[], int, android.os.Bundle)`.

### getActivities

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

```
public static @NonNull PendingIntent getActivities(
    @NonNull Context context,
    int requestCode,
    @NonNull Intent[] intents,
    int flags,
    @Nullable Bundle options,
    boolean isMutable
)
```

Retrieves a `https://developer.android.com/reference/android/app/PendingIntent.html` with mandatory mutability flag set on supported platform versions. The caller provides the flag as combination of all the other values except mutability flag. This method combines mutability flag when necessary. See `https://developer.android.com/reference/android/app/PendingIntent.html#getActivities(android.content.Context, int, android.content.Intent[], int, android.os.Bundle)`.

### getActivity

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

```
public static @Nullable PendingIntent getActivity(
    @NonNull Context context,
    int requestCode,
    @NonNull Intent intent,
    int flags,
    boolean isMutable
)
```

Retrieves a `https://developer.android.com/reference/android/app/PendingIntent.html` with mandatory mutability flag set on supported platform versions. The caller provides the flag as combination of all the other values except mutability flag. This method combines mutability flag when necessary.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/app/PendingIntent.html` | Returns an existing or new PendingIntent matching the given parameters. May return `null` only if `https://developer.android.com/reference/android/app/PendingIntent.html#FLAG_NO_CREATE` has been supplied. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/app/PendingIntent.html#getActivity(android.content.Context, int, android.content.Intent, int)` |   |

### getActivity

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

```
public static @Nullable PendingIntent getActivity(
    @NonNull Context context,
    int requestCode,
    @NonNull Intent intent,
    int flags,
    @Nullable Bundle options,
    boolean isMutable
)
```

Retrieves a `https://developer.android.com/reference/android/app/PendingIntent.html` with mandatory mutability flag set on supported platform versions. The caller provides the flag as combination of all the other values except mutability flag. This method combines mutability flag when necessary.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/app/PendingIntent.html` | Returns an existing or new PendingIntent matching the given parameters. May return `null` only if `https://developer.android.com/reference/android/app/PendingIntent.html#FLAG_NO_CREATE` has been supplied. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/app/PendingIntent.html#getActivity(android.content.Context, int, android.content.Intent, int, android.os.Bundle)` |   |

### getBroadcast

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

```
public static @Nullable PendingIntent getBroadcast(
    @NonNull Context context,
    int requestCode,
    @NonNull Intent intent,
    int flags,
    boolean isMutable
)
```

Retrieves a `https://developer.android.com/reference/android/app/PendingIntent.html` with mandatory mutability flag set on supported platform versions. The caller provides the flag as combination of all the other values except mutability flag. This method combines mutability flag when necessary.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/app/PendingIntent.html` | Returns an existing or new PendingIntent matching the given parameters. May return `null` only if `https://developer.android.com/reference/android/app/PendingIntent.html#FLAG_NO_CREATE` has been supplied. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/app/PendingIntent.html#getBroadcast(android.content.Context, int, android.content.Intent, int)` |   |

### getForegroundService

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

```
@RequiresApi(value = 26)
public static @NonNull PendingIntent getForegroundService(
    @NonNull Context context,
    int requestCode,
    @NonNull Intent intent,
    int flags,
    boolean isMutable
)
```

Retrieves a `https://developer.android.com/reference/android/app/PendingIntent.html` with mandatory mutability flag set on supported platform versions. The caller provides the flag as combination of all the other values except mutability flag. This method combines mutability flag when necessary. See `https://developer.android.com/reference/android/app/PendingIntent.html#getForegroundService(android.content.Context, int, android.content.Intent, int)` .

### getService

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

```
public static @Nullable PendingIntent getService(
    @NonNull Context context,
    int requestCode,
    @NonNull Intent intent,
    int flags,
    boolean isMutable
)
```

Retrieves a `https://developer.android.com/reference/android/app/PendingIntent.html` with mandatory mutability flag set on supported platform versions. The caller provides the flag as combination of all the other values except mutability flag. This method combines mutability flag when necessary.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/app/PendingIntent.html` | Returns an existing or new PendingIntent matching the given parameters. May return `null` only if `https://developer.android.com/reference/android/app/PendingIntent.html#FLAG_NO_CREATE` has been supplied. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/app/PendingIntent.html#getService(android.content.Context, int, android.content.Intent, int)` |   |

### send

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

```
public static void send(
    @NonNull PendingIntent pendingIntent,
    int code,
    @Nullable PendingIntent.OnFinished onFinished,
    @Nullable Handler handler
)
```

`https://developer.android.com/reference/android/app/PendingIntent.html#send()` variants that support `https://developer.android.com/reference/android/app/PendingIntent.OnFinished.html` callbacks have a bug on many API levels that the callback may be invoked even if the PendingIntent was never sent (ie, such as if the PendingIntent was canceled, and the send() invocation threw a `https://developer.android.com/reference/android/app/PendingIntent.CanceledException.html`). Using this compatibility method fixes that bug and guarantees that `https://developer.android.com/reference/android/app/PendingIntent.OnFinished.html` callbacks will only be invoked if send() completed successfully.

See `https://developer.android.com/reference/android/app/PendingIntent.html#send(int, android.app.PendingIntent.OnFinished, android.os.Handler)`.

| Throws |
|---|---|
| `https://developer.android.com/reference/android/app/PendingIntent.CanceledException.html` |   |

### send

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

```
public static void send(
    @NonNull PendingIntent pendingIntent,
    @NonNull Context context,
    int code,
    @NonNull Intent intent,
    @Nullable PendingIntent.OnFinished onFinished,
    @Nullable Handler handler
)
```

`https://developer.android.com/reference/android/app/PendingIntent.html#send()` variants that support `https://developer.android.com/reference/android/app/PendingIntent.OnFinished.html` callbacks have a bug on many API levels that the callback may be invoked even if the PendingIntent was never sent (ie, such as if the PendingIntent was canceled, and the send() invocation threw a `https://developer.android.com/reference/android/app/PendingIntent.CanceledException.html`). Using this compatibility method fixes that bug and guarantees that `https://developer.android.com/reference/android/app/PendingIntent.OnFinished.html` callbacks will only be invoked if send() completed successfully.

See `https://developer.android.com/reference/android/app/PendingIntent.html#send(android.content.Context, int, android.content.Intent, android.app.PendingIntent.OnFinished, android.os.Handler)`.

| Throws |
|---|---|
| `https://developer.android.com/reference/android/app/PendingIntent.CanceledException.html` |   |

### send

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

```
public static void send(
    @NonNull PendingIntent pendingIntent,
    @NonNull Context context,
    int code,
    @NonNull Intent intent,
    @Nullable PendingIntent.OnFinished onFinished,
    @Nullable Handler handler,
    @Nullable String requiredPermissions,
    @Nullable Bundle options
)
```

`https://developer.android.com/reference/android/app/PendingIntent.html#send()` variants that support `https://developer.android.com/reference/android/app/PendingIntent.OnFinished.html` callbacks have a bug on many API levels that the callback may be invoked even if the PendingIntent was never sent (ie, such as if the PendingIntent was canceled, and the send() invocation threw a `https://developer.android.com/reference/android/app/PendingIntent.CanceledException.html`). Using this compatibility method fixes that bug and guarantees that `https://developer.android.com/reference/android/app/PendingIntent.OnFinished.html` callbacks will only be invoked if send() completed successfully.

See `https://developer.android.com/reference/android/app/PendingIntent.html#send(android.content.Context, int, android.content.Intent, android.app.PendingIntent.OnFinished, android.os.Handler, java.lang.String, android.os.Bundle)`

| Throws |
|---|---|
| `https://developer.android.com/reference/android/app/PendingIntent.CanceledException.html` |   |