# CarAppPermission

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

*** ** * ** ***


```
public final class CarAppPermission
```

<br />

*** ** * ** ***

Defines all constants for permissions that a car app can use.

## Summary

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/car/app/CarAppPermission#ACCESS_SURFACE() = "androidx.car.app.ACCESS_SURFACE"` Permission that apps can use to get access to a canvas surface. |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/car/app/CarAppPermission#MAP_TEMPLATES() = "androidx.car.app.MAP_TEMPLATES"` Permission that apps can use to get access to templates that show a map such as `https://developer.android.com/reference/androidx/car/app/model/PlaceListMapTemplate`. |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/car/app/CarAppPermission#MEDIA_TEMPLATES() = "androidx.car.app.MEDIA_TEMPLATES"` Permission that apps can use to get access to the media templates of the car app library. |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/car/app/CarAppPermission#NAVIGATION_TEMPLATES() = "androidx.car.app.NAVIGATION_TEMPLATES"` Permission that apps can use to get access to the navigation templates of the car app library. |

| ### Public methods |
|---|---|
| `static void` | `https://developer.android.com/reference/androidx/car/app/CarAppPermission#checkHasLibraryPermission(android.content.Context,java.lang.String)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html permission )` Checks that the car app has declared the required library `permission`. |
| `static void` | `https://developer.android.com/reference/androidx/car/app/CarAppPermission#checkHasPermission(android.content.Context,java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html permission)` Checks that the car app has the given `permission` granted. |

## Constants

### ACCESS_SURFACE

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

```
public static final String ACCESS_SURFACE = "androidx.car.app.ACCESS_SURFACE"
```

Permission that apps can use to get access to a canvas surface.

This surface can be used for drawing custom content like navigation apps can use it to draw a map.

### MAP_TEMPLATES

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

```
public static final String MAP_TEMPLATES = "androidx.car.app.MAP_TEMPLATES"
```

Permission that apps can use to get access to templates that show a map such as `https://developer.android.com/reference/androidx/car/app/model/PlaceListMapTemplate`. Templates used by navigation apps that draw their own maps (e.g. `https://developer.android.com/reference/androidx/car/app/navigation/model/PlaceListNavigationTemplate`) don't require this permission.

This permission should only be declared by apps that belong to one of the categories that allow using the map templates. See [the documentation](https://developer.android.com/training/cars/apps/poi#access-map-template) for the list of such categories. An app not in one of those categories requesting this permission may be rejected upon submission. See `https://developer.android.com/reference/androidx/car/app/CarAppService` for how to declare your app's category.

### MEDIA_TEMPLATES

Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.8.0)

```
public static final String MEDIA_TEMPLATES = "androidx.car.app.MEDIA_TEMPLATES"
```

Permission that apps can use to get access to the media templates of the car app library.

This permission should only be declared by apps that belong to one of the categories that allow using the media templates (e.g. MEDIA category). An app not in one of those categories requesting this permission may be rejected upon submission. See `https://developer.android.com/reference/androidx/car/app/CarAppService` for how to declare your app's category.

### NAVIGATION_TEMPLATES

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

```
public static final String NAVIGATION_TEMPLATES = "androidx.car.app.NAVIGATION_TEMPLATES"
```

Permission that apps can use to get access to the navigation templates of the car app library.

This permission should only be declared by apps that belong to one of the categories that allow using the navigation templates. See [the documentation](https://developer.android.com/training/cars/apps/navigation#access-navigation-templates) for the list of such categories. An app not in one of those categories requesting this permission may be rejected upon submission. See `https://developer.android.com/reference/androidx/car/app/CarAppService` for how to declare your app's category.

## Public methods

### checkHasLibraryPermission

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

```
public static void checkHasLibraryPermission(
    @NonNull Context context,
    @NonNull String permission
)
```

Checks that the car app has declared the required library `permission`.

In contrast to `https://developer.android.com/reference/androidx/car/app/CarAppPermission#checkHasPermission(android.content.Context,java.lang.String)`, this method will validate that the app has at least declared the permission requested.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/SecurityException.html` | if the app does not have the required permission declared |

### checkHasPermission

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

```
public static void checkHasPermission(@NonNull Context context, @NonNull String permission)
```

Checks that the car app has the given `permission` granted.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/SecurityException.html` | if the app does not have a required permission granted |