简体   繁体   English

Android:PendingIntent是Intent的一种形式,那么PendingIntent为什么不是Intent的子类呢?

[英]Android: A PendingIntent is a form of an Intent, then why isn't PendingIntent a subclass of Intent?

They say that 他们说

Generally, when there exists an "is-a" relationship between two entities, there is an inheritance relationship in terms of OOP. 通常,当两个实体之间存在“是”关系时,就存在面向对象的继承关系。

For example 例如

"A mountain bike is a bicycle." “山地自行车就是自行车。”

So MountainBike is a subclass of Bicycle as well, as a MountainBike inherits the properties of Bicycle , and has some of its own as well. 因此, MountainBike也是Bicycle的子类, MountainBike继承了Bicycle的属性,并且也具有一些自己的属性。

Now, generally speaking a PendingIntent is an Intent, isn't it? 现在,通常来说PendingIntent是Intent,不是吗? So why is a PendingIntent a subclass of Intent? 那么为什么PendingIntent是Intent的子类?

Reference: Developer docs 参考: 开发人员文档

generally speaking a PendingIntent is an Intent, isn't it? 一般来说,PendingIntent是Intent,不是吗?

A PendingIntent can be best thought of as a wrapper around an Intent , identifying an operation to be performed (start an activity, start a service, send a broadcast) and a security context under which that operation should be performed. 最好将PendingIntent视为一个围绕Intent的包装,标识要执行的操作(启动活动,启动服务,发送广播)以及应在其下执行该操作的安全上下文。

Hence, a "has-a" relationship model is a perfectly reasonable approach here. 因此,“具有”关系模型在这里是一种完全合理的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PendingIntent发送错误的意图/ putExtra - PendingIntent sending the wrong intent / putExtra Intent .putExtra使用PendingIntent返回null - Intent .putExtra return null with PendingIntent 为什么我不能在PendingIntent中使用Intent.FLAG_ACTIVITY_NEW_TASK - Why can't I use Intent.FLAG_ACTIVITY_NEW_TASK in PendingIntent 应用程序被杀死后,PendingIntent不会保留其他意图 - PendingIntent Doesn't Keep Intent Extras After App is Killed android.content.ActivityNotFoundException:没有找到处理意图的活动{act=android.intent.action.VIEW dat=PendingIntent{} - android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=PendingIntent{ } 使用 OpenId AppAuth-Android 库时,带有隐式意图的 PendingIntent 返回取消的异常 - PendingIntent with implicit intent returning cancelled exception when using OpenId AppAuth-Android library 为什么我的Android发送电子邮件意图方法不起作用 - Why my android send email intent method isn't work 为什么 PendingIntent 会触发? - Why is the PendingIntent firing? 通知中的Android条件PendingIntent? - Android Conditional PendingIntent in Notification? Android序列化PendingIntent - Android serialize a PendingIntent
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM