CarPendingIntent


class CarPendingIntent


A class which creates PendingIntents that will start a car app, to be used in a notification action.

Summary

Public functions

java-static PendingIntent
getCarApp(context: Context, requestCode: Int, intent: Intent, flags: Int)

Creates a PendingIntent that can be sent in a notification action which will allow the targeted car app to be started when the user clicks on the action.

Public functions

getCarApp

Added in 1.1.0
java-static fun getCarApp(context: Context, requestCode: Int, intent: Intent, flags: Int): PendingIntent

Creates a PendingIntent that can be sent in a notification action which will allow the targeted car app to be started when the user clicks on the action.

See startCarApp for the supported intents that can be passed to this method.

Here is an example of usage of this method when setting a notification's intent:

    NotificationCompat.Builder builder;
    ...
    builder.setContentIntent(CarPendingIntent.getCarApp(getCarContext(), 0,
            new Intent(Intent.ACTION_VIEW).setComponent(
                    new ComponentName(getCarContext(), MyCarAppService.class)), 0));
Parameters
context: Context

the context in which this PendingIntent should use to start the car app

requestCode: Int

private request code for the sender

intent: Intent

the intent that will be sent to the car app

flags: Int

may be any of the flags allowed by getBroadcast except for FLAG_IMMUTABLE as the PendingIntent needs to be mutable to allow the host to add the necessary extras for starting the car app. If FLAG_IMMUTABLE is set, it will be unset before creating the PendingIntent

Returns
PendingIntent

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

Throws
java.lang.NullPointerException

if either context or intent are null

java.security.InvalidParameterException

if the intent is not for starting a navigation or a phone call and does not have the target car app's component name

java.lang.SecurityException

if the intent is for a different component than the one associated with the input context