public static class Notification.Action
extends Object implements Parcelable
| java.lang.Object | |
| android.app.Notification.Action | |
结构来封装可作为此通知的一部分显示的命名操作。 它必须包含一个图标,一个标签和一个PendingIntent ,当用户选择动作时将被触发。
应用程序应使用 addAction(int, CharSequence, PendingIntent)或 addAction(Notification.Action)附加操作。
Nested classes |
|
|---|---|
class |
Notification.Action.Builder |
interface |
Notification.Action.Extender |
class |
Notification.Action.WearableExtender 用于通知操作的可穿戴扩展器。 |
Inherited constants |
|---|
android.os.Parcelable
|
Fields |
|
|---|---|
public static final Creator<Notification.Action> |
CREATOR |
public PendingIntent |
actionIntent 意图在用户调用此操作时发送。 |
public int |
icon 此字段在API级别23中已弃用。请改为使用 |
public CharSequence |
title 行动的标题。 |
Public constructors |
|
|---|---|
Notification.Action(int icon, CharSequence title, PendingIntent intent) 此构造函数已在API级别23中弃用。请使用 |
|
公共方法(Public methods) |
|
|---|---|
Notification.Action |
clone() 创建并返回此对象的副本。 |
int |
describeContents() 描述此Parcelable实例的封送表示中包含的特殊对象的种类。 |
boolean |
getAllowGeneratedReplies() 返回平台是否应自动生成此 |
Bundle |
getExtras() 通过此操作获取更多元数据。 |
Icon |
getIcon() 返回表示动作的图标。 |
RemoteInput[] |
getRemoteInputs() 获取发送此操作时要从用户收集的输入列表。 |
void |
writeToParcel(Parcel out, int flags) 将此对象平铺到一个包裹中。 |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Object
|
|
android.os.Parcelable
|
|
PendingIntent actionIntent
意图在用户调用此操作时发送。 可能为空,在这种情况下,操作可能会由系统UI在禁用的演示文稿中呈现。
Notification.Action (int icon,
CharSequence title,
PendingIntent intent)
此构造函数在API级别23中已被弃用。
使用Notification.Action.Builder 。
| 参数(Parameters) | |
|---|---|
icon |
int
|
title |
CharSequence
|
intent |
PendingIntent
|
Notification.Action clone ()
创建并返回此对象的副本。 “复制”的确切含义可能取决于对象的类别。 一般意图是,对于任何对象x ,表达式:
will be true, and that the expression:x.clone() != x
will bex.clone().getClass() == x.getClass()
true, but these are not absolute requirements. While it is typically the case that:
will bex.clone().equals(x)
true, this is not an absolute requirement.
按照惯例,返回的对象应该通过调用super.clone获得。 如果一个类和它的所有超类( Object除外)都遵守这个约定,那么情况就是x.clone().getClass() == x.getClass() 。
按照惯例,这个方法返回的对象应该独立于这个对象(被克隆)。 为了实现这种独立性,可能有必要在返回super.clone之前修改返回的对象的一个或多个字段。 通常,这意味着复制包含被克隆对象的内部“深层结构”的任何可变对象,并将这些对象的引用替换为对这些副本的引用。 如果一个类只包含原始字段或对不可变对象的引用,那么通常情况下,不需要修改由super.clone返回的对象中的字段。
类Object的方法clone执行特定的克隆操作。 首先,如果该对象的类没有实现接口Cloneable ,则引发CloneNotSupportedException 。 请注意,所有数组都被视为实现接口Cloneable并且数组类型T[]的clone方法的返回类型为T[] ,其中T是任何引用或基本类型。 否则,此方法创建该对象的类的新实例,并使用该对象的相应字段的内容来初始化其所有字段,就像通过赋值一样; 这些字段的内容本身并不克隆。 因此,此方法执行此对象的“浅拷贝”,而不是“深拷贝”操作。
类 Object本身并不实现接口 Cloneable ,所以在类 Object的对象上调用 clone方法将导致在运行时抛出异常。
| 返回(Returns) | |
|---|---|
Notification.Action |
a clone of this instance. |
int describeContents ()
描述此Parcelable实例的封送表示中包含的特殊对象的种类。 例如,如果对象将在writeToParcel(Parcel, int)的输出中包含writeToParcel(Parcel, int) ,则此方法的返回值必须包含CONTENTS_FILE_DESCRIPTOR位。
| 返回(Returns) | |
|---|---|
int |
a bitmask indicating the set of special object types marshaled by this Parcelable object instance. |
boolean getAllowGeneratedReplies ()
返回平台是否应自动为此 Notification.Action生成可能的回复
| 返回(Returns) | |
|---|---|
boolean |
|
RemoteInput[] getRemoteInputs ()
获取发送此操作时要从用户收集的输入列表。 如果没有添加远程输入,可能会返回null。
| 返回(Returns) | |
|---|---|
RemoteInput[] |
|
void writeToParcel (Parcel out, int flags)
将此对象平铺到一个包裹中。
| 参数(Parameters) | |
|---|---|
out |
Parcel: The Parcel in which the object should be written. |
flags |
int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. |