zoukankan      html  css  js  c++  java
  • Android-理解PendingIntent

    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。
     整体来说PendingIntent的实现比较简单,主要和Android特定的的远程服务打交道(短信、通知、闹铃等),通常的应用无需使用。
     
    PendingIntent的机制,这篇博文很清楚了
    http://my.oschina.net/youranhongcha/blog/196933
    简单地说,pendingIntent可以理解成带有上下文信息的intent(注意它并不是继承intent的),可以延迟的执行intent的操作,有点类似系统广播,一旦发出请求就脱离activity独立执行在系统中。实质上也是个binder的代理通信。
  • 相关阅读:
    Python os 方法指南
    网站后台500错误分析
    HTML中的meta标签常用属性及其作用总结
    Python线程理论
    python之struct详解
    python之路——初识面向对象
    configparser和hashlib模块
    logging模块
    re模块
    pickle,shelve,json模块
  • 原文地址:https://www.cnblogs.com/hxy0107/p/4554554.html
Copyright © 2011-2022 走看看