# 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)

*** ** * ** ***


```
class CarAppPermission
```

<br />

*** ** * ** ***

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

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/car/app/CarAppPermission#ACCESS_SURFACE() = "androidx.car.app.ACCESS_SURFACE"` Permission that apps can use to get access to a canvas surface. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/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/kotlin/androidx/car/app/model/PlaceListMapTemplate`. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/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. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/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 functions |
|---|---|
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/car/app/CarAppPermission#checkHasLibraryPermission(android.content.Context,java.lang.String)(context: https://developer.android.com/reference/android/content/Context.html, permission: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Checks that the car app has declared the required library `permission`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/car/app/CarAppPermission#checkHasPermission(android.content.Context,java.lang.String)(context: https://developer.android.com/reference/android/content/Context.html, permission: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` 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)

```
const val ACCESS_SURFACE = "androidx.car.app.ACCESS_SURFACE": String!
```

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)

```
const val MAP_TEMPLATES = "androidx.car.app.MAP_TEMPLATES": String!
```

Permission that apps can use to get access to templates that show a map such as `https://developer.android.com/reference/kotlin/androidx/car/app/model/PlaceListMapTemplate`. Templates used by navigation apps that draw their own maps (e.g. `https://developer.android.com/reference/kotlin/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/kotlin/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)

```
const val MEDIA_TEMPLATES = "androidx.car.app.MEDIA_TEMPLATES": String!
```

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/kotlin/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)

```
const val NAVIGATION_TEMPLATES = "androidx.car.app.NAVIGATION_TEMPLATES": String!
```

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/kotlin/androidx/car/app/CarAppService` for how to declare your app's category.

## Public functions

### checkHasLibraryPermission

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

```
java-static fun checkHasLibraryPermission(context: Context, permission: String): Unit
```

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

In contrast to `https://developer.android.com/reference/kotlin/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)

```
java-static fun checkHasPermission(context: Context, permission: String): Unit
```

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 |