PendingIntent是一个等待意图,表示某个时刻要执行一个Intent,一般是用来和RemoteViews配合使用的。
几个主要方法
- getActivity():当意图发生时和startActivity()效果一样。
- getService():当意图发生时和startService()效果一样。
- getBroadcast():当意图发生时和sendBroadcast()效果一样。
与Intent的区别
- Intent是立即执行,PendingIntent是收到指示后再执行的,并且可以取消。
- Intent是需要依赖Context的,PendingIntent是不需要依赖Context的,它自带Context。
- Intent在程序关闭后就无法执行了,PendingIntent可以。