PendingIntent主要用于包装一个Intent及该Intent对应的动作。
例如,PendingIntent调用getSerivce接口,可以包装一个启动Service的Intent;
调用getActivity接口,可以包装一个启动Activity的Intent。
PendingIntent一般与AlarmManager、Notification等一起工作。
例如:
public static void setServiceAlarm(Context context, boolean isOn) {
//得到启动服务对应的Intent
Intent i = PollService.newIntent(context);
//利用PendingIntent的getService接口,得到封装后的PendingIntent
//第二个参数,是区分PendingIntent来源的请求代码
//第四个参数,是决定如何创建PendingIntent的标志位
PendingIntent pi = PendingIntent.getService(context,