他们是这样说的
Generally, when there exists an "is-a" relationship between two entities, there is an inheritance relationship in terms of OOP.
例如
"A mountain bike is a bicycle."
因此 MountainBike
也是 Bicycle
的子类,因为 MountainBike
继承了 Bicycle
的属性,并且也有一些自己的。
现在,一般来说 PendingIntent 就是一个 Intent,不是吗?那么为什么 PendingIntent 是 Intent 的子类?
最佳答案
generally speaking a PendingIntent is an Intent, isn't it?
PendingIntent
最好被认为是 Intent
的包装器,标识要执行的操作(启动 Activity 、启动服务、发送广播)以及应该执行该操作的安全上下文。
因此,“has-a”关系模型是一种非常合理的方法。
关于java - Android:PendingIntent是Intent的一种形式,那为什么PendingIntent不是Intent的子类呢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26485992/