android: PendingIntent的使用
PendingIntent的Flags的类型:
- * Flags的类型:
- FLAG_ONE_SHOT:得到的pi只能使用一次,第二次使用该pi时报错
- FLAG_NO_CREATE: 当pi不存在时,不创建,返回null
- FLAG_CANCEL_CURRENT: 每次都创建一个新的pi
- FLAG_UPDATE_CURRENT: 不存在时就创建,创建好了以后就一直用它,每次使用时都会更新pi的数据(使用较多)
- * 在AlarmManager中的使用
- Intent intent = new Intent("action", null, context, serviceClass);
- PendingIntent pi = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
- AlarmManager manager = (AlarmManager)probe.getSystemService(Context.ALARM_SERVICE);
- manager.set(AlarmManager.RTC_WAKEUP, milis, pi);
- * 在NotificationManager中的使用
- Intent intent = new Intent();
- intent.setAction("myaction");
- PendingIntent pi = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
- NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
- Notification n = new Notification();
- n.icon = R.drawable.ic_launcher;
- n.when = System.currentTimeMillis();
- n.setLatestEventInfo(this,"this is title", "this is a message", pi);
- nm.notify(0, n);
* send()方法是用,调用PendingIntent.send()会启动包装的Intent(如启动service,activity)
* cancel()方法是为了解除PendingIntent和被包装的Intent之间的关联,此时如果再调用send()方法,则会抛出CanceledException异常
android: PendingIntent的使用的更多相关文章
- android PendingIntent 使用通知传递多个参数,及不覆盖的问题
Intent updateIntent = new Intent(GetNoticeService.this, DetailGonggaoActivity.class); updateIntent.p ...
- Android PendingIntent小结
官方文档的解释 A description of an Intent and target action to perform with it. 注意有一个target action,既Pen ...
- Android · PendingIntent学习
Intent 是及时启动,intent 随所在的activity 消失而消失 PendingIntent用于处理即将发生的事情.比如在通知Notification中用于跳转页面,但不是马上跳转. ...
- Android消息通知(notification)和PendingIntent传值
通知栏的自定义布局:转:http://blog.csdn.net/vipzjyno1/article/details/25248021 拓展 实现自定义的通知栏效果: 这里要用到RemoteViews ...
- 【Android 界面效果24】Intent和PendingIntent的区别
intent英文意思是意图,pending表示即将发生或来临的事情. PendingIntent这个类用于处理即将发生的事情.比如在通知Notification中用于跳转页面,但不是马上跳转. In ...
- Android开发之PendingIntent的使用
PendingIntent,待确定的意图,等待的意图 官网链接:http://developer.android.com/reference/android/app/PendingIntent.htm ...
- Android 4.2 通知通过PendingIntent启动Activity失败的问题
今天突然发现在Android 4.2手机上点击通知消息无法打开Activity的问题,具体Logcat信息如下: 01-09 11:37:43.733: WARN/ActivityManager(92 ...
- Android中pendingIntent的深入理解
pendingIntent字面意义:等待的,未决定的Intent.要得到一个pendingIntent对象,使用方法类的静态方法 getActivity(Context, int, Intent, i ...
- Android基础知识巩固:关于PendingIntent和广播
平时使用广播的场合比较多,但细节的东西,看过了也没有总结,以至于某些场合有小问题,还是要把原理和属性搞清楚才能运用自如. 其实也是自己比较懒,先看别人的blog,有个概念再去官网看英文的能好理解一些. ...
随机推荐
- 2016---ios面试题
1.对数组中的元素去重复 例如: 1 2 3 NSArray *array = @[@"12-11", @"12-11", @"12-11&q ...
- 评估Divide and Conquer算法时间复杂度的几种策略
算法导论的第四章对于divide-conquer进行了阐述, 感觉这本书特别在,实际给出的例子并不多,更多其实是一些偏向数学性质的分析, 最重要的是告诉你该类算法分析的一般性策略. 估计 首先是估计算 ...
- 使用 IntraWeb (38) - TIWAppForm、TIWForm、TIWBaseHTMLForm、TIWBaseForm
窗体 TIWAppForm 所在单元及继承链: IWAppForm.TIWAppForm 主要成员: property OnURLRequest: TOnURLRequest //响应下面的 DoUR ...
- 发布一个UDP调试助手
UDP协议适用于那种频繁通信,但是可以容忍一些丢包的应用,比如GPS的定位应用. 调试UDP助手,可以定时发送,输出文本, 记录收到时间. 1. 该工具基于IOCP网络模型,调试UDP服务使用的一个工 ...
- SkyDrive 中Office 的版本控制功能
之前看到了这么个图片,然后想着自己过一年后也要写毕业论文… 总不能也这个样子吧,这种版本到底知道哪个是最终版啊,不用版本号也就算了……还……(据说这是张内涵图) 当年的Word 没有版本控制也就算了, ...
- jQuery学习总结(一)
jQuery当中独有的对象:jQuery对象: jQuery对象的缩写形式“$”:所以在使用时,我们都是用$来代替jQuery. 所以我们在页面元素选择或执行功能函数的时候可以这么写:$(functi ...
- networkx的绘图中文显示方块问题
修改matplotlibrc文件 font.family : sans-serif #打开该选项 font.sans-serif : Microsoft YaHei , Bitstream Vera ...
- Robot Framework-Mac版本安装
Robot Framework-Mac版本安装 Robot Framework-Windows版本安装 Robot Framework-工具简介及入门使用 Robot Framework-Databa ...
- Android 开发必备
Android 开发必备 http://www.androiddevtools.cn/ 收集整理Android开发所需的Android SDK.开发中用到的工具.Android开发教程.Android ...
- D3 学习资源
发现这个网站还是挺不错的:http://www.ourd3js.com/wordpress/