Android PendingIntent使用的特殊情况
来源:互联网 发布:矢量图网上制作软件 编辑:程序博客网 时间:2024/05/29 19:29
PendingIntent
PendingIntent的是代表了将要发生的意图,使用的时候大概涉及到几方面:
- SMS中在接收到短信发送状态的时候,可以设置一些回调
- 在警报时可以用到
在使用Notification时可以设置点击了提示消息后的动作,特殊的在Android 21以前notification可以设置一个deleteIntent来设置,消息被删除后的动作。在Android 21以后Android提供了notification的回调函数,这里不阐述。
PendingIntent的flag:
- FLAG_CANCEL_CURRENT:如果当前系统中已经存在一个相同的PendingIntent对象,那么就将先将已有的PendingIntent取消,然后重新生成一个PendingIntent对象。
- FLAG_NO_CREATE:如果当前系统中不存在相同的PendingIntent对象,系统将不会创建该PendingIntent对象而是直接返回null。
- FLAG_ONE_SHOT:该PendingIntent只作用一次。在该PendingIntent对象通过send()方法触发过后,PendingIntent将自动调用cancel()进行销毁,那么如果你再调用send()方法的话,系统将会返回一个SendIntentException。
- FLAG_UPDATE_CURRENT:如果系统中有一个和你描述的PendingIntent对等的PendingInent,那么系统将使用该PendingIntent对象,但是会使用新的Intent来更新之前PendingIntent中的Intent对象数据,例如更新Intent中的Extras。
特殊需求
在默认情况下Android系统会尽量的复用已经存在的PendingIntent,但是当我们不想复用系统中存在的PendingIntent时。我们可以使用getBroadcast(mContext, flagID, intent, PendingIntent.FLAG_UPDATE_CURRENT)的第二个参数使用不同的值就可以区分不同的PendingIntent。
ss
Intent intent = new Intent(); intent.setAction("clear"); intent.putExtra("id",flagID); PendingIntent pendingIntent= PendingIntent.getBroadcast(mContext, flagID, intent, PendingIntent.FLAG_UPDATE_CURRENT);notify.deleteIntent = pendingIntent;
0 0
- Android PendingIntent使用的特殊情况
- Android PendingIntent的使用
- PendingIntent android.app.PendingIntent.getActivity的使用
- android之PendingIntent的使用
- Android中PendingIntent的简单使用
- Android开发之PendingIntent的使用
- android之PendingIntent使用
- 管道使用的四种特殊情况!
- Android PendingIntent的理解
- PendingIntent的使用
- PendingIntent的使用
- PendingIntent的使用
- PendingIntent的使用
- 关于android中widget的PendingIntent的使用
- Android中的PendingIntent使用注意事项
- PopupWindow的特殊情况
- 异常的特殊情况
- Android PendingIntent的深入理解
- 小技巧,使用低版本的VS打开高版本的解决方案(使用VS2008打开VS2010的解决方案--同样适用于其他版本)
- .NET Core与.NET Framework、Mono之间的关系
- Android 开发中的日常积累
- AIM Tech Round 3 (Div. 1) C. Centroids(树形dp)
- 如何让选择文件的打开方式中有你的app
- Android PendingIntent使用的特殊情况
- 关系型数据库
- Coredata的版本升级
- MAMP 环境下为 php 添加 pcntl 扩展
- Shader 属性
- python版 聊天软件
- 四种线程安全的单例设计模式
- 程序员的幸福敲门
- Spring in Action(第五章 征服数据库)学习笔记