CarPendingIntent

public final class CarPendingIntent
extends Object

java.lang.Object
   ↳ androidx.car.app.notification.CarPendingIntent


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

Summary

Public methods

static PendingIntent getCarApp(Context context, int requestCode, Intent intent, int flags)

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.

Inherited methods

Public methods

getCarApp

public static PendingIntent getCarApp (Context context, 
                int requestCode, 
                Intent intent, 
                int flags)

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 CarContext.startCarApp(Intent) 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 PendingIntent.getBroadcast(Context, int, Intent, int) except for PendingIntent.FLAG_IMMUTABLE as the PendingIntent needs to be mutable to allow the host to add the necessary extras for