# Badge

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/model/Badge.java+class:androidx.car.app.model.Badge) Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.4.0)

*** ** * ** ***


```
@CarProtocol
@RequiresCarApi(value = 8)
public class Badge
```

<br />

*** ** * ** ***

Represents a badge that can be displayed as an overlay on top of an image.

A badge denotes some sort of call to action, notification, alert, etc. An example is badging of application icons in a launcher to add a number which denotes how many active notifications that application has.

Badges may have a dot which is a colored circle appearing in a different location to the icon.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/car/app/model/Badge.Builder` A builder of `https://developer.android.com/reference/androidx/car/app/model/Badge`. |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/car/app/model/Badge#equals(java.lang.Object)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html other)` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/CarColor` | `[getBackgroundColor](https://developer.android.com/reference/androidx/car/app/model/Badge#getBackgroundColor())()` **This method is deprecated.** use `https://developer.android.com/reference/androidx/car/app/model/Badge#getDotColor()` instead. <br /> |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/CarColor` | `https://developer.android.com/reference/androidx/car/app/model/Badge#getDotColor()()` Returns the dot color. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/CarIcon` | `https://developer.android.com/reference/androidx/car/app/model/Badge#getIcon()()` Returns the badge icon. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/CarColor` | `https://developer.android.com/reference/androidx/car/app/model/Badge#getIconBackgroundColor()()` Returns the icon background color. |
| `boolean` | `https://developer.android.com/reference/androidx/car/app/model/Badge#hasDot()()` Returns whether the badge has a dot. |
| `int` | `https://developer.android.com/reference/androidx/car/app/model/Badge#hashCode()()` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/car/app/model/Badge#toString()()` |

## Public methods

### equals

```
public boolean equals(@Nullable Object other)
```

### getBackgroundColor

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

```
public @Nullable CarColor [getBackgroundColor](https://developer.android.com/reference/androidx/car/app/model/Badge#getBackgroundColor())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> use `https://developer.android.com/reference/androidx/car/app/model/Badge#getDotColor()` instead.

Returns the dot background color.

### getDotColor

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

```
public @Nullable CarColor getDotColor()
```

Returns the dot color.

### getIcon

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

```
public @Nullable CarIcon getIcon()
```

Returns the badge icon.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/Badge.Builder#setIcon(androidx.car.app.model.CarIcon)` |   |

### getIconBackgroundColor

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

```
public @Nullable CarColor getIconBackgroundColor()
```

Returns the icon background color.

### hasDot

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

```
public boolean hasDot()
```

Returns whether the badge has a dot.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/Badge.Builder#setHasDot(boolean)` |   |

### hashCode

```
public int hashCode()
```

### toString

```
public @NonNull String toString()
```