# CarPackageManager

Summary:[Constants](https://developer.android.com/reference/android/car/content/pm/CarPackageManager#constants)\|[Methods](https://developer.android.com/reference/android/car/content/pm/CarPackageManager#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/car/content/pm/CarPackageManager#inhmethods)  

# CarPackageManager

`
public

final

class
CarPackageManager
`  
`

extends Object


``


`

|---|------------------------------------------|
| java.lang.Object                            ||
| ↳ | android.car.content.pm.CarPackageManager |

<br />

*** ** * ** ***

Provides car specific API related with package management.

## Summary

|                                                                                                                        ### Constants                                                                                                                         ||
|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `String` | [MANIFEST_METADATA_TARGET_CAR_VERSION](https://developer.android.com/reference/android/car/content/pm/CarPackageManager#MANIFEST_METADATA_TARGET_CAR_VERSION) *This constant is deprecated. Car version is no longer supported by the CarService.* |

|                                                                                                                                                                                                                                                   ### Public methods                                                                                                                                                                                                                                                    ||
|---------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[CarVersion](https://developer.android.com/reference/android/car/CarVersion) | ` `[getTargetCarVersion](https://developer.android.com/reference/android/car/content/pm/CarPackageManager#getTargetCarVersion())`() ` *This method is deprecated. CarVersion is no longer supported by the CarService.*                                                                                                                                                                                                                |
| ` boolean`                                                                      | ` `[isActivityDistractionOptimized](https://developer.android.com/reference/android/car/content/pm/CarPackageManager#isActivityDistractionOptimized(java.lang.String,%20java.lang.String))`(String packageName, String className) ` Returns whether an activity is distraction optimized, i.e, allowed in a restricted driving state.                                                                                                  |
| ` boolean`                                                                      | ` `[isPendingIntentDistractionOptimized](https://developer.android.com/reference/android/car/content/pm/CarPackageManager#isPendingIntentDistractionOptimized(android.app.PendingIntent))`(PendingIntent pendingIntent) ` Returns whether the given[PendingIntent](https://developer.android.com/reference/android/app/PendingIntent)represents an activity that is distraction optimized, i.e, allowed in a restricted driving state. |
| ` boolean`                                                                      | ` `[isServiceDistractionOptimized](https://developer.android.com/reference/android/car/content/pm/CarPackageManager#isServiceDistractionOptimized(java.lang.String,%20java.lang.String))`(String packageName, String className) ` Check if given service is distraction optimized, i.e, allowed in a restricted driving state.                                                                                                         |

| ### Inherited methods |
|-----------------------|---|
| From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Constants

### MANIFEST_METADATA_TARGET_CAR_VERSION

```
public static final String MANIFEST_METADATA_TARGET_CAR_VERSION
```

<br />

**This constant is deprecated.**   
Car version is no longer supported by the CarService.

Manifest metadata used to specify the minimum major and minor Car API version an app is targeting.

Format is in the form`major:minor`or`major`.

For example, for[Android 13](https://developer.android.com/reference/android/os/Build.VERSION_CODES#TIRAMISU), it would be:`
<meta-data android:name="android.car.targetCarVersion" android:value="33"/>
`

Or:`
<meta-data android:name="android.car.targetCarVersion" android:value="33:0"/>
`

And for[Android 13](https://developer.android.com/reference/android/os/Build.VERSION_CODES#TIRAMISU)first update:`
<meta-data android:name="android.car.targetCarVersion" android:value="33:1"/>
`

<br />

Constant Value: "android.car.targetCarVersion"

## Public methods

### getTargetCarVersion

```
public CarVersion getTargetCarVersion ()
```

<br />

**This method is deprecated.**   
CarVersion is no longer supported by the CarService.

Gets the Car API version targeted by app (as defined by[MANIFEST_METADATA_TARGET_CAR_VERSION](https://developer.android.com/reference/android/car/content/pm/CarPackageManager#MANIFEST_METADATA_TARGET_CAR_VERSION).

If the app manifest doesn't contain the[MANIFEST_METADATA_TARGET_CAR_VERSION](https://developer.android.com/reference/android/car/content/pm/CarPackageManager#MANIFEST_METADATA_TARGET_CAR_VERSION)metadata attribute or if the attribute format is invalid, the returned`CarVersion`will be using the[target platform
version](https://developer.android.com/reference/android/content/pm/ApplicationInfo#targetSdkVersion)as major and`0`as minor instead.

<br />

|                                                             Returns                                                              ||
|------------------------------------------------------------------------------|----------------------------------------------------|
| [CarVersion](https://developer.android.com/reference/android/car/CarVersion) | targeted Car API version (as defined above) <br /> |

### isActivityDistractionOptimized

```
public boolean isActivityDistractionOptimized (String packageName, 
                String className)
```

Returns whether an activity is distraction optimized, i.e, allowed in a restricted driving state.

<br />

|                                                                              Parameters                                                                              ||
|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|
| `packageName` | `String`: the activity's[PackageItemInfo.packageName](https://developer.android.com/reference/android/content/pm/PackageItemInfo#packageName). <br /> |
| `className`   | `String`: the activity's[PackageItemInfo.name](https://developer.android.com/reference/android/content/pm/PackageItemInfo#name). <br />               |

|                                                           Returns                                                           ||
|-----------|------------------------------------------------------------------------------------------------------------------|
| `boolean` | true if the activity is distraction optimized, false if it isn't or if the value could not be determined. <br /> |

### isPendingIntentDistractionOptimized

```
public boolean isPendingIntentDistractionOptimized (PendingIntent pendingIntent)
```

Returns whether the given[PendingIntent](https://developer.android.com/reference/android/app/PendingIntent)represents an activity that is distraction optimized, i.e, allowed in a restricted driving state.

<br />

|                                                               Parameters                                                                ||
|-----------------|------------------------------------------------------------------------------------------------------------------------|
| `pendingIntent` | `PendingIntent`: the[PendingIntent](https://developer.android.com/reference/android/app/PendingIntent)to check. <br /> |

|                                                                            Returns                                                                            ||
|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------|
| `boolean` | true if the pending intent represents an activity that is distraction optimized, false if it isn't or if the value could not be determined. <br /> |

### isServiceDistractionOptimized

```
public boolean isServiceDistractionOptimized (String packageName, 
                String className)
```

Check if given service is distraction optimized, i.e, allowed in a restricted driving state.

<br />

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |