由于App Widget只提供给我们一个可以使用RemoteViews的方法PendingIntent,因此只能采用PendingIntent方法来传递Intent。使用Intent实例化一个PendingIntent,调用PendingIntent的getActivity来启动另一个Activity。
getActivity的最后一个参数:
FLAG_CANCEL_CURRENT:若当前描述的PendingIntent已存在,则取消当前的PendingIntent,重新生成一个。
FLAG_NO_CREATE: 若当前描述的PendingIntent已经存在,则取消重新创建,返回null。
FLAG_ONE_SHOT:指PendingIntent只能使用一次。
FLAG_UPDATE_CURRENT:若当前描述的PendingIntent已经存在,则保留旧的Intent,使用新的Intent数据 替换旧的数据。
本文详细介绍了在Android AppWidget中如何使用PendingIntent来启动Activity。通过不同的标志如FLAG_CANCEL_CURRENT, FLAG_NO_CREATE, FLAG_ONE_SHOT等,文章解释了如何控制PendingIntent的行为,并探讨了它们在实际应用中的作用。
513





