Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/media/Rating#constants) \| [Inherited Constants](https://developer.android.com/reference/android/media/Rating#inhconstants) \| [Fields](https://developer.android.com/reference/android/media/Rating#lfields) \| [Methods](https://developer.android.com/reference/android/media/Rating#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/media/Rating#inhmethods)

# Rating

*** ** * ** ***

` public final class Rating `   
` extends https://developer.android.com/reference/java/lang/Object ` ` implements https://developer.android.com/reference/android/os/Parcelable `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.media.Rating |

<br />

*** ** * ** ***

A class to encapsulate rating information used as content metadata. A rating is defined by its rating style (see `https://developer.android.com/reference/android/media/Rating#RATING_HEART`, `https://developer.android.com/reference/android/media/Rating#RATING_THUMB_UP_DOWN`, `https://developer.android.com/reference/android/media/Rating#RATING_3_STARS`, `https://developer.android.com/reference/android/media/Rating#RATING_4_STARS`, `https://developer.android.com/reference/android/media/Rating#RATING_5_STARS` or `https://developer.android.com/reference/android/media/Rating#RATING_PERCENTAGE`) and the actual rating value (which may be defined as "unrated"), both of which are defined when the rating instance is constructed through one of the factory methods.

## Summary

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/media/Rating#RATING_3_STARS` A rating style with 0 to 3 stars. |
| `int` | `https://developer.android.com/reference/android/media/Rating#RATING_4_STARS` A rating style with 0 to 4 stars. |
| `int` | `https://developer.android.com/reference/android/media/Rating#RATING_5_STARS` A rating style with 0 to 5 stars. |
| `int` | `https://developer.android.com/reference/android/media/Rating#RATING_HEART` A rating style with a single degree of rating, "heart" vs "no heart". |
| `int` | `https://developer.android.com/reference/android/media/Rating#RATING_NONE` Indicates a rating style is not supported. |
| `int` | `https://developer.android.com/reference/android/media/Rating#RATING_PERCENTAGE` A rating style expressed as a percentage. |
| `int` | `https://developer.android.com/reference/android/media/Rating#RATING_THUMB_UP_DOWN` A rating style for "thumb up" vs "thumb down". |

### Inherited constants

From interface `https://developer.android.com/reference/android/os/Parcelable` `int` `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR`

Descriptor bit used with `https://developer.android.com/reference/android/os/Parcelable#describeContents()`: indicates that the Parcelable object's flattened representation includes a file descriptor.
`int` `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE`

Flag for use with `https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)`: the object being written is a return value, that is the result of a function such as "`Parcelable someFunction()`", "`void someFunction(out Parcelable)`", or "`void someFunction(inout Parcelable)`".

| ### Fields ||
|---|---|
| ` public static final https://developer.android.com/reference/android/os/Parcelable.Creator<https://developer.android.com/reference/android/media/Rating>` | `https://developer.android.com/reference/android/media/Rating#CREATOR` <br /> |

| ### Public methods ||
|---|---|
| ` int` | ` https://developer.android.com/reference/android/media/Rating#describeContents()() ` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
| ` float` | ` https://developer.android.com/reference/android/media/Rating#getPercentRating()() ` Return the percentage-based rating value. |
| ` int` | ` https://developer.android.com/reference/android/media/Rating#getRatingStyle()() ` Return the rating style. |
| ` float` | ` https://developer.android.com/reference/android/media/Rating#getStarRating()() ` Return the star-based rating value. |
| ` boolean` | ` https://developer.android.com/reference/android/media/Rating#hasHeart()() ` Return whether the rating is "heart selected". |
| ` boolean` | ` https://developer.android.com/reference/android/media/Rating#isRated()() ` Return whether there is a rating value available. |
| ` boolean` | ` https://developer.android.com/reference/android/media/Rating#isThumbUp()() ` Return whether the rating is "thumb up". |
| ` static https://developer.android.com/reference/android/media/Rating` | ` https://developer.android.com/reference/android/media/Rating#newHeartRating(boolean)(boolean hasHeart) ` Return a Rating instance with a heart-based rating. |
| ` static https://developer.android.com/reference/android/media/Rating` | ` https://developer.android.com/reference/android/media/Rating#newPercentageRating(float)(float percent) ` Return a Rating instance with a percentage-based rating. |
| ` static https://developer.android.com/reference/android/media/Rating` | ` https://developer.android.com/reference/android/media/Rating#newStarRating(int,%20float)(int starRatingStyle, float starRating) ` Return a Rating instance with a star-based rating. |
| ` static https://developer.android.com/reference/android/media/Rating` | ` https://developer.android.com/reference/android/media/Rating#newThumbRating(boolean)(boolean thumbIsUp) ` Return a Rating instance with a thumb-based rating. |
| ` static https://developer.android.com/reference/android/media/Rating` | ` https://developer.android.com/reference/android/media/Rating#newUnratedRating(int)(int ratingStyle) ` Return a Rating instance with no rating. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/media/Rating#toString()() ` Returns a string representation of the object. |
| ` void` | ` https://developer.android.com/reference/android/media/Rating#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel dest, int flags) ` Flatten this object in to a Parcel. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.
From interface ` https://developer.android.com/reference/android/os/Parcelable ` ` abstract int` ` https://developer.android.com/reference/android/os/Parcelable#describeContents()() `

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.
` abstract void` ` https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel dest, int flags) `

Flatten this object in to a Parcel.

## Constants

### RATING_3_STARS

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RATING_3_STARS
```

A rating style with 0 to 3 stars.

<br />

Constant Value: 3 (0x00000003)

### RATING_4_STARS

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RATING_4_STARS
```

A rating style with 0 to 4 stars.

<br />

Constant Value: 4 (0x00000004)

### RATING_5_STARS

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RATING_5_STARS
```

A rating style with 0 to 5 stars.

<br />

Constant Value: 5 (0x00000005)

### RATING_HEART

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RATING_HEART
```

A rating style with a single degree of rating, "heart" vs "no heart". Can be used to indicate the content referred to is a favorite (or not).

<br />

Constant Value: 1 (0x00000001)

### RATING_NONE

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RATING_NONE
```

Indicates a rating style is not supported. A Rating will never have this type, but can be used by other classes to indicate they do not support Rating.

<br />

Constant Value: 0 (0x00000000)

### RATING_PERCENTAGE

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RATING_PERCENTAGE
```

A rating style expressed as a percentage.

<br />

Constant Value: 6 (0x00000006)

### RATING_THUMB_UP_DOWN

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RATING_THUMB_UP_DOWN
```

A rating style for "thumb up" vs "thumb down".

<br />

Constant Value: 2 (0x00000002)

## Fields

### CREATOR

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final Creator<Rating> CREATOR
```

<br />

<br />

## Public methods

### describeContents

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int describeContents ()
```

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of `https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)`, the return value of this method must include the `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` bit.

<br />

| Returns ||
|---|---|
| `int` | a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either `0` or - `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` |

### getPercentRating

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public float getPercentRating ()
```

Return the percentage-based rating value.

<br />

| Returns ||
|---|---|
| `float` | a rating value greater or equal to 0.0f, or a negative value if the rating style is not percentage-based, or if it is unrated. <br /> |

### getRatingStyle

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getRatingStyle ()
```

Return the rating style.

<br />

| Returns ||
|---|---|
| `int` | one of `https://developer.android.com/reference/android/media/Rating#RATING_HEART`, `https://developer.android.com/reference/android/media/Rating#RATING_THUMB_UP_DOWN`, `https://developer.android.com/reference/android/media/Rating#RATING_3_STARS`, `https://developer.android.com/reference/android/media/Rating#RATING_4_STARS`, `https://developer.android.com/reference/android/media/Rating#RATING_5_STARS`, or `https://developer.android.com/reference/android/media/Rating#RATING_PERCENTAGE`. Value is one of the following: - `https://developer.android.com/reference/android/media/Rating#RATING_NONE` - `https://developer.android.com/reference/android/media/Rating#RATING_HEART` - `https://developer.android.com/reference/android/media/Rating#RATING_THUMB_UP_DOWN` - `https://developer.android.com/reference/android/media/Rating#RATING_3_STARS` - `https://developer.android.com/reference/android/media/Rating#RATING_4_STARS` - `https://developer.android.com/reference/android/media/Rating#RATING_5_STARS` - `https://developer.android.com/reference/android/media/Rating#RATING_PERCENTAGE` |

### getStarRating

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public float getStarRating ()
```

Return the star-based rating value.

<br />

| Returns ||
|---|---|
| `float` | a rating value greater or equal to 0.0f, or a negative value if the rating style is not star-based, or if it is unrated. <br /> |

### hasHeart

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean hasHeart ()
```

Return whether the rating is "heart selected".

<br />

| Returns ||
|---|---|
| `boolean` | true if the rating is "heart selected", false if the rating is "heart unselected", if the rating style is not `https://developer.android.com/reference/android/media/Rating#RATING_HEART` or if it is unrated. <br /> |

### isRated

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isRated ()
```

Return whether there is a rating value available.

<br />

| Returns ||
|---|---|
| `boolean` | true if the instance was not created with `https://developer.android.com/reference/android/media/Rating#newUnratedRating(int)`. <br /> |

### isThumbUp

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isThumbUp ()
```

Return whether the rating is "thumb up".

<br />

| Returns ||
|---|---|
| `boolean` | true if the rating is "thumb up", false if the rating is "thumb down", if the rating style is not `https://developer.android.com/reference/android/media/Rating#RATING_THUMB_UP_DOWN` or if it is unrated. <br /> |

### newHeartRating

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Rating newHeartRating (boolean hasHeart)
```

Return a Rating instance with a heart-based rating. Create and return a new Rating instance with a rating style of `https://developer.android.com/reference/android/media/Rating#RATING_HEART`, and a heart-based rating.

<br />

| Parameters ||
|---|---|
| `hasHeart` | `boolean`: true for a "heart selected" rating, false for "heart unselected". <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/media/Rating` | a new Rating instance. <br /> |

### newPercentageRating

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Rating newPercentageRating (float percent)
```

Return a Rating instance with a percentage-based rating. Create and return a new Rating instance with a `https://developer.android.com/reference/android/media/Rating#RATING_PERCENTAGE` rating style, and a rating of the given percentage.

<br />

| Parameters ||
|---|---|
| `percent` | `float`: the value of the rating <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/media/Rating` | null if the rating is out of range, a new Rating instance otherwise. <br /> |

### newStarRating

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Rating newStarRating (int starRatingStyle, 
                float starRating)
```

Return a Rating instance with a star-based rating. Create and return a new Rating instance with one of the star-base rating styles and the given integer or fractional number of stars. Non integer values can for instance be used to represent an average rating value, which might not be an integer number of stars.

<br />

| Parameters ||
|---|---|
| `starRatingStyle` | `int`: one of `https://developer.android.com/reference/android/media/Rating#RATING_3_STARS`, `https://developer.android.com/reference/android/media/Rating#RATING_4_STARS`, `https://developer.android.com/reference/android/media/Rating#RATING_5_STARS`. Value is one of the following: - `https://developer.android.com/reference/android/media/Rating#RATING_3_STARS` - `https://developer.android.com/reference/android/media/Rating#RATING_4_STARS` - `https://developer.android.com/reference/android/media/Rating#RATING_5_STARS` |
| `starRating` | `float`: a number ranging from 0.0f to 3.0f, 4.0f or 5.0f according to the rating style. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/media/Rating` | null if the rating style is invalid, or the rating is out of range, a new Rating instance otherwise. <br /> |

### newThumbRating

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Rating newThumbRating (boolean thumbIsUp)
```

Return a Rating instance with a thumb-based rating. Create and return a new Rating instance with a `https://developer.android.com/reference/android/media/Rating#RATING_THUMB_UP_DOWN` rating style, and a "thumb up" or "thumb down" rating.

<br />

| Parameters ||
|---|---|
| `thumbIsUp` | `boolean`: true for a "thumb up" rating, false for "thumb down". <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/media/Rating` | a new Rating instance. <br /> |

### newUnratedRating

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Rating newUnratedRating (int ratingStyle)
```

Return a Rating instance with no rating. Create and return a new Rating instance with no rating known for the given rating style.

<br />

| Parameters ||
|---|---|
| `ratingStyle` | `int`: one of `https://developer.android.com/reference/android/media/Rating#RATING_HEART`, `https://developer.android.com/reference/android/media/Rating#RATING_THUMB_UP_DOWN`, `https://developer.android.com/reference/android/media/Rating#RATING_3_STARS`, `https://developer.android.com/reference/android/media/Rating#RATING_4_STARS`, `https://developer.android.com/reference/android/media/Rating#RATING_5_STARS`, or `https://developer.android.com/reference/android/media/Rating#RATING_PERCENTAGE`. Value is one of the following: - `https://developer.android.com/reference/android/media/Rating#RATING_NONE` - `https://developer.android.com/reference/android/media/Rating#RATING_HEART` - `https://developer.android.com/reference/android/media/Rating#RATING_THUMB_UP_DOWN` - `https://developer.android.com/reference/android/media/Rating#RATING_3_STARS` - `https://developer.android.com/reference/android/media/Rating#RATING_4_STARS` - `https://developer.android.com/reference/android/media/Rating#RATING_5_STARS` - `https://developer.android.com/reference/android/media/Rating#RATING_PERCENTAGE` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/media/Rating` | null if an invalid rating style is passed, a new Rating instance otherwise. <br /> |

### toString

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String toString ()
```

Returns a string representation of the object.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string representation of the object. <br /> |

### writeToParcel

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void writeToParcel (Parcel dest, 
                int flags)
```

Flatten this object in to a Parcel.

<br />

| Parameters ||
|---|---|
| `dest` | `Parcel`: The Parcel in which the object should be written. This value cannot be `null`. <br /> |
| `flags` | `int`: Additional flags about how the object should be written. May be 0 or `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE`. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE` |