PendingIntent的相关基础知识
来源:互联网 发布:手机短信群发软件 编辑:程序博客网 时间:2024/05/17 21:48
最近因为自己不熟悉PendingIntent而犯了很多错。
PendingIntent的设计主要是为了进行一些异步操作,例如在Notification中可以点击Notification然后打开对应的东西,就是通过PendingIntent打开的
创建PendingIntent有三种方式,都是根据Intent中打开的服务而确定使用哪个
一、使用PendingIntent要选择对应的创建方式
Intent中需要打开Activity
public static PendingIntent getActivity(Context context, int requestCode, Intent intent, int flags)
Intent中需要打开,Broadcast
public static PendingIntent getBroadcast(Context context, int requestCode, Intent intent, int flags)Intent中需要打开Service
public static PendingIntent getService(Context context, int requestCode, Intent intent, int flags)二、PendingIntent的参数必须清楚了解
context
- 不解释requestCode
- 这个int值设置成相同的话,只能打开同一个服务,例如需要打开多个Service,则,这个值不能一样intent
- 设置打开的服务flags
- 这个值主要是和PendingIntent自身相关的,设置成FLAG_UPDATE_CURRENT:则每次都重新创建一个新的,用得比较多,
FLAG_CANCEL_CURRENT如果有相同的PendingIntent取消前面PendingIntent,再生成一个新的,FLAG_ONE_SHOT只能使用一次,再次修改将不会成功。PendingIntent笔记,以后再遇到相关问题再做添加和修改。
0 0
- PendingIntent的相关基础知识
- PendingIntent的相关使用说明
- Android PendingIntent的相关问题
- PendingIntent相关
- (android 基础知识) PendingIntent
- 注册表的相关基础知识
- Java相关的基础知识
- UML的相关基础知识
- UML的相关基础知识
- spark的相关基础知识
- web相关的基础知识
- shell 相关的基础知识
- IP相关的基础知识
- 单片机相关的基础知识
- 位运算相关的基础知识
- 显示屏驱动相关的基础知识
- 与网络相关的基础知识
- 天球坐标系的相关基础知识
- IO空间的静态映射基本过程
- 第八章 Spring 对 DAO 的支持 《Spring3.x》
- 文件系统 busybox and initramfs
- MapReduce实现排序功能
- Android实现分享内容到微信朋友圈
- PendingIntent的相关基础知识
- XML 语法规则
- OpenCms中文网 开通了
- 查询最大前几位或最小前几位 排序(简单笔记)
- 虚函数与多态性,虚拟继承,纯虚函数及重载、覆盖、隐藏的区别
- JS 清除字符串数组中,重复元素
- chromium for android GPU进程结构分析
- LeetCode Letter Combinations of a Phone Number
- ArcGIS教程:如何轻松的使用图例图面形状