1 定义
Intent 表示一个目的,第一个参数表示所在类,第二个参数表示目标类。
PendingIntent 即是一个Intent的描述,但是又与Intent有区别。
PendingIntent 即是一个Intent的描述,但是又与Intent有区别。
2 PendingIntent和Intent的区别
Intent 字面意思是意图,即我们的目的,我们想要做的事情,在activity中,我们可以立即执行它。
PendingIntent就是一个Intent的描述,我们可以把这个描述交给别的程序,别的程序根据这个描述在后面的别的时间做你安排做的事情。PendingIntent 相当于对intent执行了包装,我们不一定要马上执行它,我们将其包装后,传递给其他activity或application;而这时,获取到PendingIntent 的application 能够根据里面的intent 来得知发出者的意图,选择拦击或者继续传递或者执行。
PendingIntent就是一个Intent的描述,我们可以把这个描述交给别的程序,别的程序根据这个描述在后面的别的时间做你安排做的事情。PendingIntent 相当于对intent执行了包装,我们不一定要马上执行它,我们将其包装后,传递给其他activity或application;而这时,获取到PendingIntent 的application 能够根据里面的intent 来得知发出者的意图,选择拦击或者继续传递或者执行。
PendingIntent和Intent的区别:
An Intent is something that is used right now;
a PendingIntent is something that may create an Intent in the future. You will use a PendingIntent with Notifications, AlarmManager, etc.
PendingIntent就是一个Intent的描述,我们可以把这个描述交给别的程序,别的程序根据这个描述在后面的别的时间做你安排做的事情 (By giving a PendingIntent to another application, you are granting it the right to perform the operation you have specified as if the other application was yourself,就相当于PendingIntent代表了Intent)。