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,有个概念再去官网看英文的能好理解一些. ...
随机推荐
- UVALive 5009 Error Curves 三分
//#pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include& ...
- What he did
//记录组内成员具体完成工作情况,格式为:时间-事件-人物 2015-4-19 用户需求分析---主要由韩林编写,国旗,李春伟辅助编写,国旗发布文档至博客 2015-4-22 快速原型---由郭龙东完 ...
- linux下实时查看tomcat运行日志
查看实时日志: tail -f catalina.out Ctrl+c 是退出tail命令
- POJ1222_EXTENDED LIGHTS OUT
给出5*6的位置,每个位置有一个灯,一开始每个灯有各自的状态,你可以选定一些位置使得所有与这个位置相邻以及位置本身的灯都取反. 输出合法方案. 本来是找高斯消元找到这个题目的,可是....我发现可以直 ...
- PHP 数组排序
数组中的元素能够以字母或数字顺序进行升序或降序排序. PHP - 数组的排序函数 在本节中,我们将学习如下 PHP 数组排序函数: sort() - 以升序对数组排序 rsort() - 以降序对数组 ...
- Redis在CentOS6.4中的安装
首先,介绍一下Redis数据库.Redis是一种面向“键/值”对数据类型的内存数据库,可以满足我们对海量数据的读写需求. 1)redis的键只能是字符串: 2)redis的值支持多种数据类型: a:字 ...
- 深入浅出话VC++(1)——Windows程序内部运行机制
一.引言 要想熟练掌握Windows应用程序的开发,首先需要理解Windows平台下程序运行的内部机制,然而在.NET平台下,创建一个Windows桌面程序,只需要简单地选择Windows窗体应用程序 ...
- SQL中Where与Having的区别
“Where” 是一个约束声明,使用Where来约束来之数据库的数据,Where是在结果返回之前起作用的,且Where中不能使用聚合函数. “Having”是一个过滤声明,是在查询返回结果集以后对查询 ...
- oracle decode(nvl(estimate_qty,0),0,1,estimate_qty) 函數
oracle decode(nvl(estimate_qty,0),0,1,estimate_qty) 函數
- BZOJ3175 Tjoi2013 攻击装置(二分图匹配)
传送门 Description 给定一个01矩阵,其中你可以在0的位置放置攻击装置.每一个攻击装置(x,y)都可以按照"日"字攻击其周围的 8个位置(x-1,y-2),(x-2,y ...