Most visited

Recently visited

Added in API level 21

TvContentRating

public final class TvContentRating
extends Object

java.lang.Object
   ↳ android.media.tv.TvContentRating


表示电视内容评级的课程。 当电视输入服务将程序中的内容分级信息插入到数据库中时,该分类可用于生成TvContract.Programs.COLUMN_CONTENT_RATING的格式化字符串。 要创建TvContentRating对象,请使用带有有效评分系统字符串常量的TvContentRating.createRating方法。

应用程序可以通过提供内容分级系统定义XML资源(参见下面的示例)并声明一个广播接收器来过滤 ACTION_QUERY_CONTENT_RATING_SYSTEMS的清单,从而定义自己的内容分级系统。

Example: Rating system definition for the TV Parental Guidelines

The following XML example shows how the TV Parental Guidelines in the United States can be defined:

 <rating-system-definitions xmlns:android="http://schemas.android.com/apk/res/android"
     android:versionCode="1">
     <rating-system-definition android:name="US_TV"
         android:country="US"
         android:description="@string/description_us_tv">
         <sub-rating-definition android:name="US_TV_D"
             android:title="D"
             android:description="@string/description_us_tv_d" />
         <sub-rating-definition android:name="US_TV_L"
             android:title="L"
             android:description="@string/description_us_tv_l" />
         <sub-rating-definition android:name="US_TV_S"
             android:title="S"
             android:description="@string/description_us_tv_s" />
         <sub-rating-definition android:name="US_TV_V"
             android:title="V"
             android:description="@string/description_us_tv_v" />
         <sub-rating-definition android:name="US_TV_FV"
             android:title="FV"
             android:description="@string/description_us_tv_fv" />

         <rating-definition android:name="US_TV_Y"
             android:title="TV-Y"
             android:description="@string/description_us_tv_y"
             android:icon="@drawable/icon_us_tv_y"
             android:contentAgeHint="0" />
         <rating-definition android:name="US_TV_Y7"
             android:title="TV-Y7"
             android:description="@string/description_us_tv_y7"
             android:icon="@drawable/icon_us_tv_y7"
             android:contentAgeHint="7">
             <sub-rating android:name="US_TV_FV" />
         </rating-definition>
         <rating-definition android:name="US_TV_G"
             android:title="TV-G"
             android:description="@string/description_us_tv_g"
             android:icon="@drawable/icon_us_tv_g"
             android:contentAgeHint="0" />
         <rating-definition android:name="US_TV_PG"
             android:title="TV-PG"
             android:description="@string/description_us_tv_pg"
             android:icon="@drawable/icon_us_tv_pg"
             android:contentAgeHint="14">
             <sub-rating android:name="US_TV_D" />
             <sub-rating android:name="US_TV_L" />
             <sub-rating android:name="US_TV_S" />
             <sub-rating android:name="US_TV_V" />
         </rating-definition>
         <rating-definition android:name="US_TV_14"
             android:title="TV-14"
             android:description="@string/description_us_tv_14"
             android:icon="@drawable/icon_us_tv_14"
             android:contentAgeHint="14">
             <sub-rating android:name="US_TV_D" />
             <sub-rating android:name="US_TV_L" />
             <sub-rating android:name="US_TV_S" />
             <sub-rating android:name="US_TV_V" />
         </rating-definition>
         <rating-definition android:name="US_TV_MA"
             android:title="TV-MA"
             android:description="@string/description_us_tv_ma"
             android:icon="@drawable/icon_us_tv_ma"
             android:contentAgeHint="17">
             <sub-rating android:name="US_TV_L" />
             <sub-rating android:name="US_TV_S" />
             <sub-rating android:name="US_TV_V" />
         </rating-definition>
         <rating-order>
             <rating android:name="US_TV_Y" />
             <rating android:name="US_TV_Y7" />
         </rating-order>
         <rating-order>
             <rating android:name="US_TV_G" />
             <rating android:name="US_TV_PG" />
             <rating android:name="US_TV_14" />
             <rating android:name="US_TV_MA" />
         </rating-order>
     </rating-system-definition>
 </rating-system-definitions>

System defined rating strings

The following strings are defined by the system to provide a standard way to create TvContentRating objects.

例如,要创建一个代表TV-PG评分的对象,并在美国的电视“家长指南”中使用暗示式对话和粗俗的语言,可以使用以下代码片段:

 TvContentRating rating = TvContentRating.createRating(
         "com.android.tv",
         "US_TV",
         "US_TV_PG",
         "US_TV_D", "US_TV_L");
 

System defined string for domains

Constant Value 描述
com.android.tv Used for creating system defined content ratings

System defined strings for rating systems

Constant Value 描述
AR_TV TV content rating system for Argentina
AU_TV TV content rating system for Australia
BR_TV TV content rating system for Brazil
CA_TV_EN TV content rating system for Canada (English)
CA_TV_FR TV content rating system for Canada (French)
DVB DVB content rating system
ES_DVB DVB content rating system for Spain
FR_DVB DVB content rating system for France
ISDB ISDB content rating system
KR_TV TV content rating system for South Korea
SG_TV TV content rating system for Singapore
US_MV Movie content rating system for the United States
US_TV TV content rating system for the United States

System defined strings for ratings

Rating System Constant Value 描述
AR_TV AR_TV_ATP Suitable for all audiences. Programs may contain mild violence, language and mature situations
AR_TV_SAM_13 Suitable for ages 13 and up. Programs may contain mild to moderate language and mild violence and sexual references
AR_TV_SAM_16 Suitable for ages 16 and up. Programs may contain more intensive violence and coarse language, partial nudity and moderate sexual references
AR_TV_SAM_18 Suitable for mature audiences only. Programs contain strong violence, coarse language and explicit sexual references
AU_TV AU_TV_P Recommended for younger children aged between 2 and 11 years
AU_TV_C Recommended for older children aged between 5 and 14 years
AU_TV_G Recommended for all ages
AU_TV_PG Parental guidance is recommended for young viewers under 15
AU_TV_M Recommended for mature audiences aged 15 years and over
AU_TV_MA Not suitable for children and teens under 15, due to sexual descriptions, course language, adult themes or drug use
AU_TV_AV Not suitable for children and teens under 15. This category is used specifically for violent programs
AU_TV_R Not for children under 18. Content may include graphic violence, sexual situations, coarse language and explicit drug use
BR_TV BR_TV_L Content is suitable for all audiences
BR_TV_10 Content suitable for viewers over the age of 10
BR_TV_12 Content suitable for viewers over the age of 12
BR_TV_14 Content suitable for viewers over the age of 14
BR_TV_16 Content suitable for viewers over the age of 16
BR_TV_18 Content suitable for viewers over the age of 18
CA_TV_EN CA_TV_EN_EXEMPT Exempt from ratings
CA_TV_EN_C Suitable for children ages 2–7
CA_TV_EN_C8 Suitable for children ages 8 and older
CA_TV_EN_G Suitable for the entire family
CA_TV_EN_PG May contain moderate violence, profanity, nudity, and sexual references
CA_TV_EN_14 Intended for viewers ages 14 and older
CA_TV_EN_18 Intended for viewers ages 18 and older
CA_TV_FR CA_TV_FR_E Exempt from ratings
CA_TV_FR_G Appropriate for all ages
CA_TV_FR_8 Appropriate for children 8
CA_TV_FR_13 Suitable for children 13
CA_TV_FR_16 Recommended for children over the age of 16
CA_TV_FR_18 Only to be viewed by adults
DVB DVB_4 Recommended for ages 4 and over
DVB_5 Recommended for ages 5 and over
DVB_6 Recommended for ages 6 and over
DVB_7 Recommended for ages 7 and over
DVB_8 Recommended for ages 8 and over
DVB_9 Recommended for ages 9 and over
DVB_10 Recommended for ages 10 and over
DVB_11 Recommended for ages 11 and over
DVB_12 Recommended for ages 12 and over
DVB_13 Recommended for ages 13 and over
DVB_14 Recommended for ages 14 and over
DVB_15 Recommended for ages 15 and over
DVB_16 Recommended for ages 16 and over
DVB_17 Recommended for ages 17 and over
DVB_18 Recommended for ages 18 and over
ES_DVB ES_DVB_ALL Recommended for all ages
ES_DVB_C Recommended for children
ES_DVB_X Recommended for adults
ES_DVB_4 Recommended for ages 4 and over
ES_DVB_5 Recommended for ages 5 and over
ES_DVB_6 Recommended for ages 6 and over
ES_DVB_7 Recommended for ages 7 and over
ES_DVB_8 Recommended for ages 8 and over
ES_DVB_9 Recommended for ages 9 and over
ES_DVB_10 Recommended for ages 10 and over
ES_DVB_11 Recommended for ages 11 and over
ES_DVB_12 Recommended for ages 12 and over
ES_DVB_13 Recommended for ages 13 and over
ES_DVB_14 Recommended for ages 14 and over
ES_DVB_15 Recommended for ages 15 and over
ES_DVB_16 Recommended for ages 16 and over
ES_DVB_17 Recommended for ages 17 and over
ES_DVB_18 Recommended for ages 18 and over
FR_DVB FR_DVB_U Recommended for all ages
FR_DVB_4 Recommended for ages 4 and over
FR_DVB_5 Recommended for ages 5 and over
FR_DVB_6 Recommended for ages 6 and over
FR_DVB_7 Recommended for ages 7 and over
FR_DVB_8 Recommended for ages 8 and over
FR_DVB_9 Recommended for ages 9 and over
FR_DVB_10 Recommended for ages 10 and over
FR_DVB_11 Recommended for ages 11 and over
FR_DVB_12 Recommended for ages 12 and over
FR_DVB_13 Recommended for ages 13 and over
FR_DVB_14 Recommended for ages 14 and over
FR_DVB_15 Recommended for ages 15 and over
FR_DVB_16 Recommended for ages 16 and over
FR_DVB_17 Recommended for ages 17 and over
FR_DVB_18 Recommended for ages 18 and over
ISDB ISDB_4 Recommended for ages 4 and over
ISDB_5 Recommended for ages 5 and over
ISDB_6 Recommended for ages 6 and over
ISDB_7 Recommended for ages 7 and over
ISDB_8 Recommended for ages 8 and over
ISDB_9 Recommended for ages 9 and over
ISDB_10 Recommended for ages 10 and over
ISDB_11 Recommended for ages 11 and over
ISDB_12 Recommended for ages 12 and over
ISDB_13 Recommended for ages 13 and over
ISDB_14 Recommended for ages 14 and over
ISDB_15 Recommended for ages 15 and over
ISDB_16 Recommended for ages 16 and over
ISDB_17 Recommended for ages 17 and over
ISDB_18 Recommended for ages 18 and over
ISDB_19 Recommended for ages 19 and over
ISDB_20 Recommended for ages 20 and over
KR_TV KR_TV_ALL Appropriate for all ages
KR_TV_7 May contain material inappropriate for children younger than 7, and parental discretion should be used
KR_TV_12 May deemed inappropriate for those younger than 12, and parental discretion should be used
KR_TV_15 May be inappropriate for children under 15, and that parental discretion should be used
KR_TV_19 For adults only
SG_TV SG_TV_G Suitable for all ages
SG_TV_PG Suitable for all but parents should guide their young
SG_TV_PG13 Suitable for persons aged 13 and above but parental guidance is advised for children below 13
SG_TV_NC16 Suitable for persons aged 16 and above
SG_TV_M18 Suitable for persons aged 18 and above
SG_TV_R21 Suitable for adults aged 21 and above
US_MV US_MV_G General audiences
US_MV_PG Parental guidance suggested
US_MV_PG13 Parents strongly cautioned
US_MV_R Restricted, under 17 requires accompanying parent or adult guardian
US_MV_NC17 No one 17 and under admitted
US_TV US_TV_Y This program is designed to be appropriate for all children
US_TV_Y7 This program is designed for children age 7 and above
US_TV_G Most parents would find this program suitable for all ages
US_TV_PG This program contains material that parents may find unsuitable for younger children
US_TV_14 This program contains some material that many parents would find unsuitable for children under 14 years of age
US_TV_MA This program is specifically designed to be viewed by adults and therefore may be unsuitable for children under 17

System defined strings for sub-ratings

Rating System Constant Value 描述
BR_TV BR_TV_D Drugs
Applicable to BR_TV_L, BR_TV_10, BR_TV_12, BR_TV_14, BR_TV_16, and BR_TV_18
BR_TV_S Sex
Applicable to BR_TV_L, BR_TV_10, BR_TV_12, BR_TV_14, BR_TV_16, and BR_TV_18
BR_TV_V Violence
Applicable to BR_TV_L, BR_TV_10, BR_TV_12, BR_TV_14, BR_TV_16, and BR_TV_18
US_TV US_TV_D Suggestive dialogue (Usually means talks about sex)
Applicable to US_TV_PG, and US_TV_14
US_TV_L Coarse language
Applicable to US_TV_PG, US_TV_14, and US_TV_MA
US_TV_S Sexual content
Applicable to US_TV_PG, US_TV_14, and US_TV_MA
US_TV_V Violence
Applicable to US_TV_PG, US_TV_14, and US_TV_MA
US_TV_FV Fantasy violence (Children's programming only)
Applicable to US_TV_Y7

Summary

Fields

public static final TvContentRating UNRATED

等级常数表示未分级的内容。

Public methods

final boolean contains(TvContentRating rating)

如果此评分与指定评分具有相同的主评分,并且该评分的次评分包含另一评分的评分,则返回 true

static TvContentRating createRating(String domain, String ratingSystem, String rating, String... subRatings)

使用预定义的内容分级字符串创建一个 TvContentRating对象。

boolean equals(Object obj)

指示其他某个对象是否“等于”这一个。

String flattenToString()

返回一个明确描述 TvContentRating对象中包含的评级信息的字符串。

String getDomain()

返回此 TvContentRating对象的域。

String getMainRating()

返回此 TvContentRating对象的主要评级。

String getRatingSystem()

返回此 TvContentRating对象的评分系统。

List<String> getSubRatings()

返回此 TvContentRating对象的不可修改的子分级字符串 List

int hashCode()

返回对象的哈希码值。

static TvContentRating unflattenFromString(String ratingString)

从以前从 flattenToString()创建的字符串中恢复一个 TvContentRating对象。

Inherited methods

From class java.lang.Object

Fields

UNRATED

Added in API level 23
TvContentRating UNRATED

等级常数表示未分级的内容。 用于处理内容分级信息丢失的情况。

电视输入服务可以用这个常数调用isRatingBlocked(TvContentRating)以确定它们是否应该阻止未分级的内容。 随后使用相同的常量调用notifyContentBlocked(TvContentRating)会通知应用程序当前节目内容被家长控制阻止。

Public methods

contains

Added in API level 24
boolean contains (TvContentRating rating)

如果此评分与指定评分具有相同的主评分,并且该评分的次评分包含另一评分的评分,则返回 true

例如,代表具有S(色情内容)和V(暴力)的TV-PG的 TvContentRating对象包含TV-PG,TV-PG / S,TV-PG / V及其本身。

Parameters
rating TvContentRating: The TvContentRating to check.
Returns
boolean true if this object contains rating, false otherwise.

createRating

Added in API level 21
TvContentRating createRating (String domain, 
                String ratingSystem, 
                String rating, 
                String... subRatings)

用预定义的内容分级字符串创建一个 TvContentRating对象。

Parameters
domain String: The domain string. For example, "com.android.tv".
ratingSystem String: The rating system string. For example, "US_TV".
rating String: The content rating string. For example, "US_TV_PG".
subRatings String: The sub-rating strings. For example, "US_TV_D" and "US_TV_L".
Returns
TvContentRating A TvContentRating object.
Throws
IllegalArgumentException If domain, ratingSystem or rating is null.

equals

Added in API level 21
boolean equals (Object obj)

指示其他某个对象是否“等于”这一个。

equals方法在非空对象引用上实现等价关系:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

equals类的方法Object实现了对象上最可能的等价关系; 也就是说,对于任何非空参考值xy ,当且仅当xy引用同一对象( x == y的值为true )时,此方法返回true

请注意,无论何时覆盖此方法,通常都需要覆盖 hashCode方法,以维护 hashCode方法的一般合同,该方法声明等同对象必须具有相同的哈希代码。

Parameters
obj Object: the reference object with which to compare.
Returns
boolean true if this object is the same as the obj argument; false otherwise.

flattenToString

Added in API level 21
String flattenToString ()

返回一个字符串,用于明确描述TvContentRating对象中包含的评级信息。 之后可以通过unflattenFromString(String)从该字符串中恢复对象。

Returns
String a string containing the rating information, which can later be stored in the database.

也可以看看:

getDomain

Added in API level 21
String getDomain ()

返回此 TvContentRating对象的域。

Returns
String

getMainRating

Added in API level 21
String getMainRating ()

返回此 TvContentRating对象的主要评级。

Returns
String

getRatingSystem

Added in API level 21
String getRatingSystem ()

返回此 TvContentRating对象的评分系统。

Returns
String

getSubRatings

Added in API level 21
List<String> getSubRatings ()

返回此 TvContentRating对象的不可修改的子分级字符串 List

Returns
List<String>

hashCode

Added in API level 21
int hashCode ()

返回对象的哈希码值。 为了散列表的好处而支持此方法,例如由HashMap提供的HashMap

hashCode的总合同是:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

尽量合理实用,类Object定义的hashCode方法确实为不同的对象返回不同的整数。 (这通常通过将对象的内部地址转换为整数来实现,但Java TM编程语言不需要此实现技术。)

Returns
int a hash code value for this object.

unflattenFromString

Added in API level 21
TvContentRating unflattenFromString (String ratingString)

从以前从 flattenToString()创建的字符串中恢复一个 TvContentRating对象。

Parameters
ratingString String: The string returned by flattenToString().
Returns
TvContentRating the TvContentRating object containing the domain, rating system, rating and sub-ratings information encoded in ratingString.

也可以看看:

Hooray!