# StarRating

# StarRating

Artifact:[androidx.media3:media3-common](https://developer.android.com/jetpack/androidx/releases/media3)  
[View Source](https://cs.android.com/search?q=file:androidx/media3/common/StarRating.java+class:androidx.media3.common.StarRating)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/common/StarRating "View this page in Java")

<br />

```
class StarRating : Rating
```

<br />

|---|---|-----------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)                                          |||
| ↳ | [androidx.media3.common.Rating](https://developer.android.com/reference/kotlin/androidx/media3/common/Rating)            ||
|   | ↳ | [androidx.media3.common.StarRating](https://developer.android.com/reference/kotlin/androidx/media3/common/StarRating) |

*** ** * ** ***

A rating expressed as a fractional number of stars.

## Summary

|                                                                                                                                                                                                                                                                                                 ### Public constructors                                                                                                                                                                                                                                                                                                 |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [StarRating](https://developer.android.com/reference/kotlin/androidx/media3/common/StarRating#StarRating(int))`(maxStars: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Creates a unrated instance with`maxStars`.                                                                                                                                                                                                                                                               |
| [StarRating](https://developer.android.com/reference/kotlin/androidx/media3/common/StarRating#StarRating(int,float))`(` ` maxStars: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` starRating: @`[FloatRange](https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange)`(from = 0.0) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) `)` Creates a rated instance with`maxStars`and the given fractional number of stars. |

|                                              ### Public functions                                               |
|-----------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                             | [equals](https://developer.android.com/reference/kotlin/androidx/media3/common/StarRating#equals(java.lang.Object))`(obj: `[Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`?)`                                                                                                                                                                                                                         |
| `java-static `[StarRating](https://developer.android.com/reference/kotlin/androidx/media3/common/StarRating)`!` | `@`[UnstableApi](https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi) [fromBundle](https://developer.android.com/reference/kotlin/androidx/media3/common/StarRating#fromBundle(android.os.Bundle))`(bundle: `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)`!)` Restores a`StarRating`from a[Bundle](https://developer.android.com/reference/android/os/Bundle.html). |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                     | [hashCode](https://developer.android.com/reference/kotlin/androidx/media3/common/StarRating#hashCode())`()`                                                                                                                                                                                                                                                                                                                        |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                             | [isRated](https://developer.android.com/reference/kotlin/androidx/media3/common/StarRating#isRated())`()` Whether the rating exists or not.                                                                                                                                                                                                                                                                                        |
| [Bundle](https://developer.android.com/reference/android/os/Bundle.html)`!`                                     | `@`[UnstableApi](https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi) [toBundle](https://developer.android.com/reference/kotlin/androidx/media3/common/StarRating#toBundle())`()` Returns a[Bundle](https://developer.android.com/reference/android/os/Bundle.html)representing the information stored in this rating.                                                                          |

|                                                                               ### Public properties                                                                                |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|
| `@`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [maxStars](https://developer.android.com/reference/kotlin/androidx/media3/common/StarRating#maxStars())     |
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)                                                                                                    | [starRating](https://developer.android.com/reference/kotlin/androidx/media3/common/StarRating#starRating()) |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ### Inherited functions                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From[androidx.media3.common.Rating](https://developer.android.com/reference/kotlin/androidx/media3/common/Rating) |---------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `java-static `[Rating](https://developer.android.com/reference/kotlin/androidx/media3/common/Rating)`!` | `@`[UnstableApi](https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi) [fromBundle](https://developer.android.com/reference/kotlin/androidx/media3/common/Rating#fromBundle(android.os.Bundle))`(bundle: `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)`!)` Restores a`Rating`from a[Bundle](https://developer.android.com/reference/android/os/Bundle.html). | |

## Public constructors

### StarRating

```
StarRating(maxStars: @IntRange(from = 1) Int)
```

Creates a unrated instance with`maxStars`. If`maxStars`is not a positive integer, it will throw an[IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException.html).  

|                                                                                          Parameters                                                                                          |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------|
| `maxStars: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The maximum number of stars this rating can have. |

### StarRating

```
StarRating(
    maxStars: @IntRange(from = 1) Int,
    starRating: @FloatRange(from = 0.0) Float
)
```

Creates a rated instance with`maxStars`and the given fractional number of stars. Non-integer values may be used to represent an average rating value. If`maxStars`is not a positive integer or`starRating`is out of range, it will throw an[IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException.html).  

|                                                                                                Parameters                                                                                                |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------|
| `maxStars: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)             | The maximum number of stars this rating can have.                  |
| `starRating: @`[FloatRange](https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange)`(from = 0.0) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | A fractional number of stars of this rating from`0f`to` maxStars`. |

## Public functions

### equals

```
fun equals(obj: Any?): Boolean
```  

### fromBundle

```
@UnstableApi
java-static fun fromBundle(bundle: Bundle!): StarRating!
```

Restores a`StarRating`from a[Bundle](https://developer.android.com/reference/android/os/Bundle.html).  

### hashCode

```
fun hashCode(): Int
```  

### isRated

```
fun isRated(): Boolean
```

Whether the rating exists or not.  

### toBundle

```
@UnstableApi
fun toBundle(): Bundle!
```

Returns a[Bundle](https://developer.android.com/reference/android/os/Bundle.html)representing the information stored in this rating.  

## Public properties

### maxStars

```
val maxStars: @IntRange(from = 1) Int
```  

### starRating

```
val starRating: Float
```