PendingIntentCompat


public final class PendingIntentCompat


Helper for accessing features in PendingIntent.

Summary

Public methods

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

Retrieves a PendingIntent with mandatory mutability flag set on supported platform versions.

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

Retrieves a PendingIntent with mandatory mutability flag set on supported platform versions.

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

Retrieves a PendingIntent with mandatory mutability flag set on supported platform versions.

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

Retrieves a PendingIntent with mandatory mutability flag set on supported platform versions.

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

Retrieves a PendingIntent with mandatory mutability flag set on supported platform versions.

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

Retrieves a PendingIntent with mandatory mutability flag set on supported platform versions.

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

Retrieves a PendingIntent with mandatory mutability flag set on supported platform versions.

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

send variants that support PendingIntent.OnFinished 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 PendingIntent.CanceledException).

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

send variants that support PendingIntent.OnFinished 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 PendingIntent.CanceledException).

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
)

send variants that support PendingIntent.OnFinished 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 PendingIntent.CanceledException).

Public methods

getActivities

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

Retrieves a PendingIntent 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 getActivities.

getActivities

Added in 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 PendingIntent 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 getActivities.

getActivity

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

Retrieves a PendingIntent 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
@Nullable PendingIntent

Returns an existing or new PendingIntent matching the given parameters. May return null only if FLAG_NO_CREATE has been supplied.

See also
getActivity

getActivity

Added in 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 PendingIntent 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
@Nullable PendingIntent

Returns an existing or new PendingIntent matching the given parameters. May return null only if FLAG_NO_CREATE has been supplied.

See also
getActivity

getBroadcast

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

Retrieves a PendingIntent 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
@Nullable PendingIntent

Returns an existing or new PendingIntent matching the given parameters. May return null only if FLAG_NO_CREATE has been supplied.

See also
getBroadcast

getForegroundService

Added in 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 PendingIntent 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 getForegroundService .

getService

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

Retrieves a PendingIntent 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
@Nullable PendingIntent

Returns an existing or new PendingIntent matching the given parameters. May return null only if FLAG_NO_CREATE has been supplied.

See also
getService

send

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

send variants that support PendingIntent.OnFinished 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 PendingIntent.CanceledException). Using this compatibility method fixes that bug and guarantees that PendingIntent.OnFinished callbacks will only be invoked if send() completed successfully.

See send.

send

Added in 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
)

send variants that support PendingIntent.OnFinished 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 PendingIntent.CanceledException). Using this compatibility method fixes that bug and guarantees that PendingIntent.OnFinished callbacks will only be invoked if send() completed successfully.

See send.

send

Added in 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
)

send variants that support PendingIntent.OnFinished 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 PendingIntent.CanceledException). Using this compatibility method fixes that bug and guarantees that PendingIntent.OnFinished callbacks will only be invoked if send() completed successfully.

See send