CarContext


public class CarContext extends ContextWrapper

Known direct subclasses
TestCarContext

The CarContext that is used for testing.


The CarContext class is a ContextWrapper subclass accessible to your and Screen instances, which provides access to car services such as the ScreenManager for managing the screen stack, the AppManager for general app-related functionality such as accessing a surface for drawing your navigation app's map, and the NavigationManager used by turn-by-turn navigation apps to communicate navigation metadata and other navigation-related events with the host. See Access the navigation templates for a comprehensive list of library functionality available to navigation apps.

Whenever you use a CarContext to load resources, the following configuration elements come from the car screen's configuration, and not the phone:

  • Screen width.
  • Screen height.
  • Screen pixel density (DPI).
  • Night mode (See isDarkMode).

Please refer here, on how to use configuration qualifiers in your resources.

See also
getCarService

Summary

Constants

static final String
ACTION_NAVIGATE = "androidx.car.app.action.NAVIGATE"

Standard action for navigating to a location.

static final String
APP_SERVICE = "app"

Manages all app events such as invalidating the UI, showing a toast, etc.

static final String
CAR_SERVICE = "car"

Internal usage only.

static final String
@RequiresCarApi(value = 2)
CONSTRAINT_SERVICE = "constraints"

Manages constraints for the app as enforced by the connected host.

static final String
EXTRA_START_CAR_APP_BINDER_KEY = "androidx.car.app.extra.START_CAR_APP_BINDER_KEY"

Key for including a IStartCarApp in the notification Intent, for starting the app if it has not been opened yet.

static final String
@RequiresCarApi(value = 3)
HARDWARE_SERVICE = "hardware"

Manages access to androidx.car.app.hardware properties, sensors and actions.

static final String

Manages the media requests from 3p apps such as providing a media session token,

static final String
NAVIGATION_SERVICE = "navigation"

Manages all navigation events such as starting navigation when focus is granted, abandoning navigation when focus is lost, etc.

static final String
SCREEN_SERVICE = "screen"

Manages the screens of the app, including the screen stack.

static final String
SUGGESTION_SERVICE = "suggestion"

Manages posting suggestion events

Public methods

void

Requests to finish the car app.

@Nullable ComponentName

Return the component (service or activity) that invoked this car app.

int

Retrieves the API level negotiated with the host.

@NonNull Object

Provides a car service by name.

@NonNull T
<T> getCarService(@NonNull Class<T> serviceClass)

Returns a car service by class.

@NonNull String

Gets the name of the car service that is represented by the specified class.

@Nullable HostInfo

Returns information about the host attached to this service.

@NonNull OnBackPressedDispatcher

Returns the OnBackPressedDispatcher that will be triggered when the user clicks a back button.

boolean

Returns true if the car is set to dark mode.

void
requestPermissions(
    @NonNull List<String> permissions,
    @NonNull OnRequestPermissionsListener listener
)

Requests the provided permissions from the user, calling the provided listener in the main thread.

void
requestPermissions(
    @NonNull List<String> permissions,
    @NonNull Executor executor,
    @NonNull OnRequestPermissionsListener listener
)

Requests the provided permissions from the user.

void
@RequiresCarApi(value = 2)
setCarAppResult(int resultCode, @Nullable Intent data)

Sets the result of this car app.

void

Starts a car app on the car screen.

static void
startCarApp(@NonNull Intent notificationIntent, @NonNull Intent appIntent)

This method is deprecated.

use getCarApp to create the pending intent for the notification action.

Inherited Constants

From android.content.Context
static final String
ACCESSIBILITY_SERVICE = "accessibility"
static final String
ACCOUNT_SERVICE = "account"
static final String
ACTIVITY_SERVICE = "activity"
static final String
ALARM_SERVICE = "alarm"
static final String
APPWIDGET_SERVICE = "appwidget"
static final String
APP_OPS_SERVICE = "appops"
static final String
APP_SEARCH_SERVICE = "app_search"
static final String
AUDIO_SERVICE = "audio"
static final String
BATTERY_SERVICE = "batterymanager"
static final int
static final int
static final int
static final int
static final int
static final int
static final int
BIND_EXTERNAL_SERVICE = -2147483648
static final long
BIND_EXTERNAL_SERVICE_LONG = 4611686018427387904
static final int
static final int
static final int
static final int
static final int
static final int
static final String
BIOMETRIC_SERVICE = "biometric"
static final String
BLOB_STORE_SERVICE = "blob_store"
static final String
BLUETOOTH_SERVICE = "bluetooth"
static final String
BUGREPORT_SERVICE = "bugreport"
static final String
CAMERA_SERVICE = "camera"
static final String
CAPTIONING_SERVICE = "captioning"
static final String
CARRIER_CONFIG_SERVICE = "carrier_config"
static final String
CLIPBOARD_SERVICE = "clipboard"
static final String
COMPANION_DEVICE_SERVICE = "companiondevice"
static final String
CONNECTIVITY_DIAGNOSTICS_SERVICE = "connectivity_diagnostics"
static final String
CONNECTIVITY_SERVICE = "connectivity"
static final String
CONSUMER_IR_SERVICE = "consumer_ir"
static final int
static final int
static final int
static final String
CREDENTIAL_SERVICE = "credential"
static final String
CROSS_PROFILE_APPS_SERVICE = "crossprofileapps"
static final int
static final int
static final String
DEVICE_LOCK_SERVICE = "device_lock"
static final String
DEVICE_POLICY_SERVICE = "device_policy"
static final String
DISPLAY_HASH_SERVICE = "display_hash"
static final String
DISPLAY_SERVICE = "display"
static final String
DOMAIN_VERIFICATION_SERVICE = "domain_verification"
static final String
DOWNLOAD_SERVICE = "download"
static final String
DROPBOX_SERVICE = "dropbox"
static final String
EUICC_SERVICE = "euicc"
static final String
FILE_INTEGRITY_SERVICE = "file_integrity"
static final String
FINGERPRINT_SERVICE = "fingerprint"
static final String
GAME_SERVICE = "game"
static final String
GRAMMATICAL_INFLECTION_SERVICE = "grammatical_inflection"
static final String
HARDWARE_PROPERTIES_SERVICE = "hardware_properties"
static final String
HEALTHCONNECT_SERVICE = "healthconnect"
static final String
INPUT_METHOD_SERVICE = "input_method"
static final String
INPUT_SERVICE = "input"
static final String
IPSEC_SERVICE = "ipsec"
static final String
JOB_SCHEDULER_SERVICE = "jobscheduler"
static final String
KEYGUARD_SERVICE = "keyguard"
static final String
LAUNCHER_APPS_SERVICE = "launcherapps"
static final String
LAYOUT_INFLATER_SERVICE = "layout_inflater"
static final String
LOCALE_SERVICE = "locale"
static final String
LOCATION_SERVICE = "location"
static final String
MEDIA_COMMUNICATION_SERVICE = "media_communication"
static final String
MEDIA_METRICS_SERVICE = "media_metrics"
static final String
MEDIA_PROJECTION_SERVICE = "media_projection"
static final String
MEDIA_ROUTER_SERVICE = "media_router"
static final String
MEDIA_SESSION_SERVICE = "media_session"
static final String
MIDI_SERVICE = "midi"
static final int
MODE_APPEND = 32768
static final int
static final int

This field is deprecated.

static final int
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final String
static final String
NFC_SERVICE = "nfc"
static final String
NOTIFICATION_SERVICE = "notification"
static final String
NSD_SERVICE = "servicediscovery"
static final String
OVERLAY_SERVICE = "overlay"
static final String
PEOPLE_SERVICE = "people"
static final String
PERFORMANCE_HINT_SERVICE = "performance_hint"
static final String
POWER_SERVICE = "power"
static final String
PRINT_SERVICE = "print"
static final int
static final int
static final int
static final String
RESTRICTIONS_SERVICE = "restrictions"
static final String
ROLE_SERVICE = "role"
static final String
SEARCH_SERVICE = "search"
static final String
SENSOR_SERVICE = "sensor"
static final String
SHORTCUT_SERVICE = "shortcut"
static final String
STATUS_BAR_SERVICE = "statusbar"
static final String
STORAGE_SERVICE = "storage"
static final String
STORAGE_STATS_SERVICE = "storagestats"
static final String
SYSTEM_HEALTH_SERVICE = "systemhealth"
static final String
TELECOM_SERVICE = "telecom"
static final String
TELEPHONY_IMS_SERVICE = "telephony_ims"
static final String
static final String
TELEPHONY_SUBSCRIPTION_SERVICE = "telephony_subscription_service"
static final String
TEXT_CLASSIFICATION_SERVICE = "textclassification"
static final String
static final String
TV_INPUT_SERVICE = "tv_input"
static final String
TV_INTERACTIVE_APP_SERVICE = "tv_interactive_app"
static final String
UI_MODE_SERVICE = "uimode"
static final String
USAGE_STATS_SERVICE = "usagestats"
static final String
USB_SERVICE = "usb"
static final String
USER_SERVICE = "user"
static final String
VIBRATOR_MANAGER_SERVICE = "vibrator_manager"
static final String
VIBRATOR_SERVICE = "vibrator"

This field is deprecated.

static final String
VIRTUAL_DEVICE_SERVICE = "virtualdevice"
static final String
VPN_MANAGEMENT_SERVICE = "vpn_management"
static final String
WALLPAPER_SERVICE = "wallpaper"
static final String
WIFI_AWARE_SERVICE = "wifiaware"
static final String
WIFI_P2P_SERVICE = "wifip2p"
static final String
static final String
WIFI_SERVICE = "wifi"
static final String
WINDOW_SERVICE = "window"

Inherited methods

From android.content.Context
final int
getColor(int id)
final ColorStateList
final Drawable
getDrawable(int id)
final String
getString(int resId)
final T
<T> getSystemService(Class<T> serviceClass)
final CharSequence
getText(int resId)
final TypedArray
void
void
sendBroadcastWithMultiplePermissions(
    Intent intent,
    String[] receiverPermissions
)
From android.content.ContextWrapper
void
boolean
bindIsolatedService(
    Intent service,
    int flags,
    String instanceName,
    Executor executor,
    ServiceConnection conn
)
boolean
bindService(Intent service, ServiceConnection conn, int flags)
boolean
bindServiceAsUser(
    Intent service,
    ServiceConnection conn,
    int flags,
    UserHandle user
)
int
int
checkCallingOrSelfUriPermission(Uri uri, int modeFlags)
int[]
checkCallingOrSelfUriPermissions(List<Uri> uris, int modeFlags)
int
int
checkCallingUriPermission(Uri uri, int modeFlags)
int[]
checkCallingUriPermissions(List<Uri> uris, int modeFlags)
int
checkPermission(String permission, int pid, int uid)
int
int
checkUriPermission(Uri uri, int pid, int uid, int modeFlags)
int[]
checkUriPermissions(List<Uri> uris, int pid, int uid, int modeFlags)
void

This method is deprecated.

Context
Context
Context
Context
Context
createDeviceContext(int deviceId)
Context
Context
Context
createPackageContext(String packageName, int flags)
Context
createWindowContext(int type, Bundle options)
String[]
boolean
boolean
boolean
void
void
enforceCallingOrSelfUriPermission(
    Uri uri,
    int modeFlags,
    String message
)
void
enforceCallingPermission(String permission, String message)
void
enforceCallingUriPermission(Uri uri, int modeFlags, String message)
void
enforcePermission(String permission, int pid, int uid, String message)
void
enforceUriPermission(
    Uri uri,
    int pid,
    int uid,
    int modeFlags,
    String message
)
String[]
Context
ApplicationInfo
AssetManager
AttributionSource
String
Context
File
ClassLoader
File
ContentResolver
File
File
int
File
getDir(String name, int mode)
Display
File
File[]
File
File[]
File[]

This method is deprecated.

File
File
Executor
Looper
File
File
File[]
String
String
PackageManager
String
String
ContextParams
Resources
SharedPreferences
getSharedPreferences(String name, int mode)
Object
String
Resources.Theme
Drawable

This method is deprecated.

int

This method is deprecated.

int

This method is deprecated.

void
grantUriPermission(String toPackage, Uri uri, int modeFlags)
boolean
boolean
boolean
boolean
moveDatabaseFrom(Context sourceContext, String name)
boolean
moveSharedPreferencesFrom(Context sourceContext, String name)
FileInputStream
FileOutputStream
openFileOutput(String name, int mode)
SQLiteDatabase
openOrCreateDatabase(
    String name,
    int mode,
    SQLiteDatabase.CursorFactory factory
)
Drawable

This method is deprecated.

void
void
Intent
void

This method is deprecated.

void

This method is deprecated.

void
void
revokeUriPermission(Uri uri, int modeFlags)
void
void
void
sendOrderedBroadcast(Intent intent, String receiverPermission)
void
sendOrderedBroadcastAsUser(
    Intent intent,
    UserHandle user,
    String receiverPermission,
    BroadcastReceiver resultReceiver,
    Handler scheduler,
    int initialCode,
    String initialData,
    Bundle initialExtras
)
void

This method is deprecated.

void

This method is deprecated.

void
sendStickyOrderedBroadcast(
    Intent intent,
    BroadcastReceiver resultReceiver,
    Handler scheduler,
    int initialCode,
    String initialData,
    Bundle initialExtras
)

This method is deprecated.

void
sendStickyOrderedBroadcastAsUser(
    Intent intent,
    UserHandle user,
    BroadcastReceiver resultReceiver,
    Handler scheduler,
    int initialCode,
    String initialData,
    Bundle initialExtras
)

This method is deprecated.

void
setTheme(int resid)
void

This method is deprecated.

void
startActivities(Intent[] intents)
void
ComponentName
boolean
startInstrumentation(
    ComponentName className,
    String profileFile,
    Bundle arguments
)
void
startIntentSender(
    IntentSender intent,
    Intent fillInIntent,
    int flagsMask,
    int flagsValues,
    int extraFlags
)
ComponentName
boolean
void
void
void
void
void
updateServiceGroup(ServiceConnection conn, int group, int importance)

Constants

ACTION_NAVIGATE

Added in 1.0.0
public static final String ACTION_NAVIGATE = "androidx.car.app.action.NAVIGATE"

Standard action for navigating to a location.

Used as the Intent's action for starting a navigation via startCarApp.

APP_SERVICE

Added in 1.0.0
public static final String APP_SERVICE = "app"

Manages all app events such as invalidating the UI, showing a toast, etc.

CAR_SERVICE

Added in 1.0.0
public static final String CAR_SERVICE = "car"

Internal usage only. Top level binder to host.

CONSTRAINT_SERVICE

Added in 1.1.0
@RequiresCarApi(value = 2)
public static final String CONSTRAINT_SERVICE = "constraints"

Manages constraints for the app as enforced by the connected host.

EXTRA_START_CAR_APP_BINDER_KEY

Added in 1.0.0
public static final String EXTRA_START_CAR_APP_BINDER_KEY = "androidx.car.app.extra.START_CAR_APP_BINDER_KEY"

Key for including a IStartCarApp in the notification Intent, for starting the app if it has not been opened yet.

HARDWARE_SERVICE

Added in 1.1.0
@RequiresCarApi(value = 3)
public static final String HARDWARE_SERVICE = "hardware"

Manages access to androidx.car.app.hardware properties, sensors and actions.

MEDIA_PLAYBACK_SERVICE

Added in 1.4.0
@ExperimentalCarApi
public static final String MEDIA_PLAYBACK_SERVICE = "media_playback"

Manages the media requests from 3p apps such as providing a media session token,

Added in 1.0.0
public static final String NAVIGATION_SERVICE = "navigation"

Manages all navigation events such as starting navigation when focus is granted, abandoning navigation when focus is lost, etc.

SCREEN_SERVICE

Added in 1.0.0
public static final String SCREEN_SERVICE = "screen"

Manages the screens of the app, including the screen stack.

SUGGESTION_SERVICE

Added in 1.3.0
public static final String SUGGESTION_SERVICE = "suggestion"

Manages posting suggestion events

Public methods

finishCarApp

Added in 1.0.0
public void finishCarApp()

Requests to finish the car app.

Call this when your app is done and should be closed. The Session corresponding to this CarContext will become State.DESTROYED.

At some point after this call, the OS will destroy your CarAppService.

This method should not be called until the Lifecycle.State of the context's Session is at least CREATED.

getCallingComponent

Added in 1.1.0
@RequiresCarApi(value = 2)
public @Nullable ComponentName getCallingComponent()

Return the component (service or activity) that invoked this car app.

This is who the data in setCarAppResult will be sent to. You can use this information to validate that the recipient is allowed to receive the data.

Starting applications for result is not implemented in Android Auto, and this method will always return null for that platform.

Returns
@Nullable ComponentName

the ComponentName of the component that will receive your reply, or null if none

getCarAppApiLevel

Added in 1.0.0
public int getCarAppApiLevel()

Retrieves the API level negotiated with the host.

API levels are used during client and host connection handshake to negotiate a common set of elements that both processes can understand. Different devices might have different host versions. Each of these hosts will support a range of API levels, as a way to provide backwards compatibility.

Applications can also provide forward compatibility, by declaring support for a getMinCarAppApiLevel lower than getLatestCarAppApiLevel. See getMinCarAppApiLevel for more details.

Clients must ensure no elements annotated with a RequiresCarApi value higher than returned by this method is used at runtime.

Refer to RequiresCarApi description for more details on how to implement forward compatibility.

This method should not be called until the Lifecycle.State of the context's Session is at least CREATED.

Returns
int

a value between getMinCarAppApiLevel and getLatestCarAppApiLevel. In case of incompatibility, the host will disconnect from the service before completing the handshake

Throws
java.lang.IllegalStateException

if invoked before the connection handshake with the host has been completed (for example, before onCreateScreen)

getCarService

Added in 1.0.0
public @NonNull Object getCarService(@NonNull String name)

Provides a car service by name.

The class of the returned object varies by the requested name.

Currently supported car services, and their respective classes, are:

APP_SERVICE

An AppManager for communication between the app and the host.

NAVIGATION_SERVICE

A NavigationManager for management of navigation updates.

SCREEN_SERVICE

A ScreenManager for management of Screens.

CONSTRAINT_SERVICE

A ConstraintManager for management of content limits.

HARDWARE_SERVICE

A CarHardwareManager for interacting with car hardware (e.g. sensors) data.

SUGGESTION_SERVICE

A SuggestionManager for posting androidx.car.app.suggestion.model.Suggestions.

This method should not be called until the Lifecycle.State of the context's Session is at least CREATED.

Parameters
@NonNull String name

The name of the car service requested. This should be one of APP_SERVICE, NAVIGATION_SERVICE or SCREEN_SERVICE

Returns
@NonNull Object

The car service instance

Throws
java.lang.IllegalArgumentException

if name does not refer to a valid car service

java.lang.IllegalStateException

if the service referred by name can not be instantiated (e.g. missing library dependency)

java.lang.NullPointerException

if name is null

getCarService

Added in 1.0.0
public @NonNull T <T> getCarService(@NonNull Class<T> serviceClass)

Returns a car service by class.

See getCarService for a list of the supported car services.

This method should not be called until the Lifecycle.State of the context's Session is at least CREATED.

Parameters
@NonNull Class<T> serviceClass

the class of the requested service

Throws
java.lang.IllegalArgumentException

if serviceClass is not the class of a supported car service

java.lang.IllegalStateException

if serviceClass can not be instantiated (e.g. missing library dependency)

java.lang.NullPointerException

if serviceClass is null

getCarServiceName

Added in 1.0.0
public @NonNull String getCarServiceName(@NonNull Class<Object> serviceClass)

Gets the name of the car service that is represented by the specified class.

This method should not be called until the Lifecycle.State of the context's Session is at least CREATED.

Parameters
@NonNull Class<Object> serviceClass

the class of the requested service

Returns
@NonNull String

the car service name to use with getCarService

Throws
java.lang.IllegalArgumentException

if serviceClass is not the class of a supported car service

java.lang.NullPointerException

if serviceClass is null

See also
getCarService

getHostInfo

Added in 1.1.0
public @Nullable HostInfo getHostInfo()

Returns information about the host attached to this service.

This method should not be called until the Lifecycle.State of the context's Session is at least CREATED.

Returns
@Nullable HostInfo

The HostInfo of the connected host, or null if it is not available.

See also
HostInfo

getOnBackPressedDispatcher

Added in 1.0.0
public @NonNull OnBackPressedDispatcher getOnBackPressedDispatcher()

Returns the OnBackPressedDispatcher that will be triggered when the user clicks a back button.

The default back press behavior is to call pop.

To override the default behavior, register a androidx.activity.OnBackPressedCallback via calling addCallback. Using the LifecycleOwner ensures that your callback is only registered while its Lifecycle is at least STARTED.

If there is a androidx.activity.OnBackPressedCallback that is added and enabled, and you'd like to remove the top Screen as a part of the callback, you MUST call pop in the callback. The default behavior is overridden when you have a callback enabled.

isDarkMode

Added in 1.0.0
public boolean isDarkMode()

Returns true if the car is set to dark mode.

Navigation applications must redraw their map with the proper dark colors when the host determines that conditions warrant it, as signaled by the value returned by this method.

Whenever the dark mode status changes, you will receive a call to onCarConfigurationChanged.

This method should not be called until the Lifecycle.State of the context's Session is at least CREATED.

requestPermissions

Added in 1.1.0
public void requestPermissions(
    @NonNull List<String> permissions,
    @NonNull OnRequestPermissionsListener listener
)

Requests the provided permissions from the user, calling the provided listener in the main thread.

The app can define a branded background to the permission request through the carPermissionActivityLayout theme attribute, by declaring it in a theme and referencing the theme from the androidx.car.app.theme metadata.

In AndroidManifest.xml, under the application element corresponding to the car app:

<meta-data
  android:name="androidx.car.app.theme"
  android:resource="@style/CarAppTheme"/>
The CarAppTheme style is defined as any other themes in a resource file:
<resources>
  <style name="CarAppTheme">
    <item name="carPermissionActivityLayout">@layout/app_branded_background</item>
  </style>
</resources>

The default behavior is to have no background behind the permission request.

See also
requestPermissions

=

requestPermissions

Added in 1.1.0
public void requestPermissions(
    @NonNull List<String> permissions,
    @NonNull Executor executor,
    @NonNull OnRequestPermissionsListener listener
)

Requests the provided permissions from the user.

When the result is available, the listener provided will be called using the Executor provided.

This method should be called using a androidx.car.app.model.ParkedOnlyOnClickListener.

If this method is called while the host deems it is unsafe (for example, when the user is driving), the permission(s) will not be requested from the user.

If the Session is destroyed before the user accepts or rejects the permissions, the callback will not be executed.

Platform Considerations Using this method allows the app to work across all platforms supported by the library with the same API (e.g. Android Auto on mobile devices and Android Automotive OS on native car heads unit). On a mobile platform, this method will start an activity that will display the platform's permissions UI over it. You can choose to not use this method and instead implement your own activity and code to request the permissions in that platform. On Automotive OS however, distraction-optimized activities other than CarAppActivity are not allowed and may be rejected during app submission. See CarAppActivity for more details.
Parameters
@NonNull List<String> permissions

the runtime permissions to request from the user

@NonNull Executor executor

the executor that will be used for calling the callback provided

@NonNull OnRequestPermissionsListener listener

listener that will be notified when the user takes action on the permission request

Throws
java.lang.NullPointerException

if any of executor, permissions or callback are null

setCarAppResult

Added in 1.1.0
@RequiresCarApi(value = 2)
public void setCarAppResult(int resultCode, @Nullable Intent data)

Sets the result of this car app.

In Android Automotive OS, this is equivalent to setResult. Call this to set the result that your CarAppActivity will return to its caller.

This method is not implemented in Android Auto.

Parameters
int resultCode

the result code to propagate back to the originating app, often RESULT_CANCELED or RESULT_OK

@Nullable Intent data

the data to propagate back to the originating app

Throws
java.lang.IllegalStateException

if the method is not supported in the current platform.

startCarApp

Added in 1.0.0
public void startCarApp(@NonNull Intent intent)

Starts a car app on the car screen.

The target application will get the Intent via onCreateScreen or onNewIntent.

Supported Intents:

An Intent to navigate.

The action must be ACTION_NAVIGATE.
The data URI scheme must be either a latitude,longitude pair, or a + separated string query as follows:
1) "geo:12.345,14.8767" for a latitude, longitude pair.
2) "geo:0,0?q=123+Main+St,+Seattle,+WA+98101" for an address.
3) "geo:0,0?q=a+place+name" for a place to search for.

An Intent to make a phone call.

The Intent must be created as defined here.

An Intent to start this app in the car.

The component name of the intent must be the one for the CarAppService that contains this CarContext. If the component name is for a different component, the method will throw a SecurityException.

This method should not be called until the Lifecycle.State of the context's Session is at least CREATED.

Parameters
@NonNull Intent intent

the Intent to send to the target application

Throws
java.lang.SecurityException

if the app attempts to start a different app explicitly or does not have permissions for the requested action

androidx.car.app.HostException

if the remote call fails. For example, if the intent cannot be handled by the car host.

java.lang.NullPointerException

if intent is null

startCarApp

Added in 1.0.0
Deprecated in 1.1.0
public static void startCarApp(@NonNull Intent notificationIntent, @NonNull Intent appIntent)

Starts the car app on the car screen.

Use this method if the app has received a broadcast due to a notification action.

Parameters
@NonNull Intent notificationIntent

the Intent that the app received via broadcast due to a user taking an action on a notification in the car

@NonNull Intent appIntent

the Intent to use for starting the car app. See startCarApp for the documentation on valid Intents

Throws
java.security.InvalidParameterException

if notificationIntent is not an Intent received from a broadcast, due to an action taken by the user in the car

java.lang.NullPointerException

if either notificationIntent or appIntent are null