> Documentation index: https://developer.android.com/reference/llms.txt

# NotificationCompat.Metric

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core.md.txt) [View Source](https://cs.android.com/search?q=file:androidx/core/app/NotificationCompat.java+class:androidx.core.app.NotificationCompat.Metric) Added in [1.19.0](https://developer.android.com/jetpack/androidx/releases/core.md.txt#1.19.0)

*** ** * ** ***


```
@RequiresApi(value = 26)
public final class NotificationCompat.Metric
```

<br />

*** ** * ** ***

A metric, used with `MetricStyle`, and which has a value and a label.

## Summary

| ### Nested types |
|---|
| `public final class NotificationCompat.Metric.FixedDate extends NotificationCompat.Metric.MetricValue` A metric value for showing a date. |
| `public final class NotificationCompat.Metric.FixedFloat extends NotificationCompat.Metric.MetricValue` Metric corresponding to a floating point value. |
| `public final class NotificationCompat.Metric.FixedInt extends NotificationCompat.Metric.MetricValue` Metric corresponding to an integer value. |
| `public final class NotificationCompat.Metric.FixedText extends NotificationCompat.Metric.MetricValue` Metric corresponding to a text value. |
| `public final class NotificationCompat.Metric.FixedTime extends NotificationCompat.Metric.MetricValue` A metric value for showing a clock time. |
| `public abstract class NotificationCompat.Metric.MetricValue` A superclass for the various value types used by the `Metric` class. |
| `public final class NotificationCompat.Metric.TimeDifference extends NotificationCompat.Metric.MetricValue` This represents a timer, a stopwatch, or a countdown to an event. |

| ### Public constructors |
|---|
| `Metric( @NonNull NotificationCompat.Metric.MetricValue value, @NonNull CharSequence label )` Creates a Metric with the specified value and label. |
| `Metric( @NonNull NotificationCompat.Metric.MetricValue value, @NonNull CharSequence label, int semanticStyle )` Creates a Metric with the specified value, label, and semantic style. |

| ### Public methods |
|---|---|
| `boolean` | `equals(Object obj)` |
| `@NonNull CharSequence` | `getLabel()` A label for the metric. |
| `int` | `getSemanticStyle()` Applies semantics to the metric. |
| `@NonNull NotificationCompat.Metric.MetricValue` | `getValue()` A value for the metric. |
| `int` | `hashCode()` |
| `@NonNull String` | `toString()` |

## Public constructors

### Metric

Added in [1.19.0](https://developer.android.com/jetpack/androidx/releases/core.md.txt#1.19.0)

```
public Metric(
    @NonNull NotificationCompat.Metric.MetricValue value,
    @NonNull CharSequence label
)
```

Creates a Metric with the specified value and label.

| Parameters |
|---|---|
| `@NonNull NotificationCompat.Metric.MetricValue value` | one of the subclasses of `MetricValue`, such as `FixedInt` |
| `@NonNull CharSequence label` | metric label -- should be 10 characters or fewer |

### Metric

Added in [1.19.0](https://developer.android.com/jetpack/androidx/releases/core.md.txt#1.19.0)

```
public Metric(
    @NonNull NotificationCompat.Metric.MetricValue value,
    @NonNull CharSequence label,
    int semanticStyle
)
```

Creates a Metric with the specified value, label, and semantic style.

| Parameters |
|---|---|
| `@NonNull NotificationCompat.Metric.MetricValue value` | one of the subclasses of `MetricValue`, such as `FixedInt` |
| `@NonNull CharSequence label` | metric label -- should be 10 characters or fewer |
| `int semanticStyle` | semantic style applied to the metric. When the notification `is promoted` the metric value will be displayed (e.g. colored) according to this style. |

## Public methods

### equals

```
public boolean equals(Object obj)
```

### getLabel

Added in [1.19.0](https://developer.android.com/jetpack/androidx/releases/core.md.txt#1.19.0)

```
public @NonNull CharSequence getLabel()
```

A label for the metric.

The space allocated to this will depend on the number of metrics on the notification, but it's recommended to keep this to 10 characters or fewer.

### getSemanticStyle

Added in [1.19.0](https://developer.android.com/jetpack/androidx/releases/core.md.txt#1.19.0)

```
public int getSemanticStyle()
```

Applies semantics to the metric. When the notification `is promoted` the metric value will be displayed (e.g. colored) according to this style.

### getValue

Added in [1.19.0](https://developer.android.com/jetpack/androidx/releases/core.md.txt#1.19.0)

```
public @NonNull NotificationCompat.Metric.MetricValue getValue()
```

A value for the metric.

### hashCode

```
public int hashCode()
```

### toString

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