一、pendingIntent的字面意义:等待的,未决定的Intent。intent:意图,pending:即将发生或将要来临的事情。

  1.pendingIntent对象,使用的静态方法:

    getActivity(Content ,int ,Intent,int)跳转到一个Activity组件。
    getBroadcast(Content ,int ,Intent,int)打开一个广播组件。
    getService(Content,int Intent,int)打开一个服务组件

  2.pending是一个特殊的Intent,主要区别:Intent是立即执行,pending不是立刻执行的。pending执行的操作实质上是参数Intent的参数,但是执行需要满足一定的条件。
    Pending是对Intent的一个包装,使用PendingIntent时,在外部App执行调用Intent的,在pendingIntent中,保存着当前App的Content,就算当前执行的App已经不存在了,也能通过pending中的content执行Intent。还可以处理Intent处理后的操作。

二、主要用途:通知Notification的发送,短消息SmsManager的发送,警报器AlarmManager的执行等。

 

posted on 2019-07-26 15:44  leill  阅读(677)  评论(0编辑  收藏  举报