PendingIntent的Flags】的更多相关文章

PendingIntent是一个Intent的描述.包装,给予了这个PendingIntent 的组件在指定的事件发生或指定的时间到达时启动Activty.Service或者Broadcast. 根据是要启动Activity.Service还是Broadcast分别对应一个获取PendingIntent的方法 public static PendingIntent getActivity(Context context, int requestCode, Intent intent, int f…
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…
如果你有这方面的需求,那你实践的时候可能会发现,多个Notifycation点击的时候会传递相同的数据. 通常情况下我们可能这样写. Notification notification = new Notification(R.drawable.ic_launcher_9, name , System.currentTimeMillis()); Intent intent = new Intent(mContext , ThemeInfo.class); Bundle bundle = new…
一:普通Notification 1.内容标题setContentTitle(...) 2.大图标setLargeIcon(Bitmap) 3.内容setContentText(...) 4.内容附加信息setContentInfo(...) 5.小图标setSmallIcon(...) 6.时间(自动生成) 二:Notification的创建 1>实例化一个NotificationCompat.Builder对象2>调用builder的相关方法对notification设置标题,图标,内容等…
最近博客写的少了,以后还得经常更新才行. ------------------------------------------------------------ 1.特定业务需求下try cath 异常需要catch可能的RuntimeException,否则可能出现catch不全导致的意外问题(如app崩溃). 之所以将此问题放在第一位,是因为前阵子中项目中出现了此类情况,并且这种情况很容易不注意或遗忘,但其错误却是致命的. 在Java/Android开发中,当调用一个函数时,此函数抛出一个…
1.什么是RemoteView? 答:其实就是一种特殊的view结构,这种view 能够跨进程传输.并且这种remoteview 还提供了一些方法 可以跨进程更新界面.具体在android里面 一个是通知 一个是桌面小部件. 这2个就是remoteview 最直接的应用了 2.RemoteView在通知上的应用? 答:这里给出一个小例子,比较粗糙 仅做演示使用. //默认样式的notification private void normalStyleNotification() { Intent…
今天总结了一下Notification的使用,发现这个控件在版本上有点扯淡.API11和API16两个分水岭,导致菜鸟在学习的时候比较吃力,受影响的外界因素是多样的,其中比较重要的就是你测试的android设备的版本,我刚开始使用的android版本为android4.0.4,我在程序中使用的是API16以上的方法,正好android4.0对应的API为API15,相差了一个版本,导致发出通知的时候程序挂掉. 如果你要兼容低版本的android系统的话(API11以下),建议使用一下方法: No…
/** * 后台执行的定时任务 */ public class LongRunningService extends Service { @Override public IBinder onBind(Intent intent) { return null; } @Override public int onStartCommand(Intent intent,int flags,int startId) { new Thread(){ public void run() { Log.i("T…
一.状态栏通知(Notification): 如果需要查看消息,可以拖动状态栏到屏幕下方即可查看消息.发送消息的代码如下: public void sendNotice(View v){ int icon=android.R.drawable.stat_notify_chat; //第一个参数为图标,第二个参数为标题,第三个为通知时间 Notification notification = new Notification(icon, "通知", System.currentTimeM…
在网上查询了下.Android版本号更新通知栏带进度条,醉了,基本都是复制过来.有的代码不全,连源代码下载都没有.有下载也须要积分,还不能用,真黑心啊!!之前自己也写过自己定义通知栏Notification,想了还是自己写吧. 由于在通知栏更新,须要訪问网络下载.就写了个服务,在服务中实现了下载个更新. 先看MainActivity代码: package com.wsj.wsjdemo; import android.os.Bundle; import android.app.Activity;…
(1) android.app.PendingIntent.FLAG_UPDATE_CURRENT 如果PendingIntent已经存在,保留它并且只替换它的extra数据. (2) android.app.PendingIntent.FLAG_CANCEL_CURRENT (3) android.app.PendingIntent.FLAG_ONE_SHOT PendingIntent只能使用一次.调用了实例方法send()之后,它会被自动cancel掉,再次调用send()方法将失败. (…
遇到如下问题 service中得一随机数 用alarmmanager 发送PendingIntent的时候,receiver收到的随机数不变. pendingintent传值经常获取到的值是第一次的值或者null,这个跟第二个参数和最后一个参数选择有关系. 将最后一个参数设置成 PendingIntent.FLAG_UPDATE_CURRENT 即可解决问题. 总结一下pendingIntent的常用FLAG标签: FLAG_ONE_SHOT:this PendingIntent can onl…
// 为发送通知的按钮的点击事件定义事件处理方法 public void send() {///// 第一步:获取NotificationManager NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); ///// 第二步:定义Notification Intent intentAct = new Intent(this, OnePage.class); i…
Notification和NotificationManager :可以用来实现可视化的消息通知等,比如:下载进度显示,消息显示,广播的内容等 RemoteViews :用于创建自定义的Notification PendingIntent :用于处理即将发生的事情:pendingintent中保存了当前App的上下文Context,使得外部App可以如当前App一样执行pendingintent中的意图Intent,就算在执行时当前App已经不存在了,也能通过存在于pendingintent里的…
通知栏的自定义布局:转:http://blog.csdn.net/vipzjyno1/article/details/25248021 拓展 实现自定义的通知栏效果: 这里要用到RemoteViews这个类.实现以下2种自定义布局. 注意: Notification的自定义布局是RemoteViews,和其他RemoteViews一样,在自定义视图布局文件中,仅支持FrameLayout.LinearLayout.RelativeLayout三种布局控件和AnalogClock.Chronome…
notification.setLatestEventInfo(context, title, message, pendingIntent);    在target为23时删除了该方法,我们应该使用build模式 低于API Level 11版本,也就是Android 2.3.3以下的系统中,setLatestEventInfo()函数是唯一的实现方法. Intent  intent = new Intent(this,MainActivity);  PendingIntent pending…
pendingIntent字面意义:等待的,未决定的Intent. 要得到一个pendingIntent对象,使用方法类的静态方法 通过getActivity(Context context, int requestCode, Intent intent, int flags)从系统取得一个用于启动一个Activity的PendingIntent对象, 通过getService(Context context, int requestCode, Intent intent, int flags)…
一.定义 PendingIntent表示待定.等待.即将发生的意思.Intent表示的是立刻发生. PendingIntent的主要方法: int requestCode:表示请求码,跟intent是一样的. int flags:常见的类型 FLAG_ONE_SHOT:当前描述的PendingIntent只能被使用一次,同类型的通知栏只能使用一次,后续的通知栏单击后将无法打开. FLAG_NO_CREATE:当之前的PendingIntent不存在,则返回null(基本用不到) FLAG_CAN…
1.AlarmManager的作用与PendingIntent的关系 顾名思义,就是“提醒”,是Android中常用的一种系统级别的提示服务,在特定的时刻为我们广播一个指定的Intent.简单的说就是我们设定一个时间,然后在该时间到来时,AlarmManager为我们广播一个我们设定的Intent,通常我们使用 PendingIntent,PendingIntent可以理解为Intent的封装包,简单的说就是在Intent上在加个指定的动作.在使用Intent的时候,我们还需要在执行startA…
pendingIntent字面意义:等待的,未决定的Intent.要得到一个pendingIntent对象,使用方法类的静态方法 getActivity(Context, int, Intent, int),getBroadcast(Context, int, Intent, int),getService(Context, int, Intent, int)  分别对应着Intent的3个行为,跳转到一个activity组件.打开一个广播组件和打开一个服务组件.参数有4个,比较重要的事第三个和…
Intent是一个意图,一个描述了想要启动一个Activity.Broadcast或是Service的意图.它主要持有的信息是它想要启动的组件(Activity.Broadcast或是Service),在开发操作中,需要通过 startActivity , startService 或sendBroadcast 方法来启动这个意图执行某些操作!! PendingIntent可以认为是对Intent的包装,实际上就是,供当前App或之外的其他App调用,而常见的是供外部App使用,外部App执行这…
一概念 PendingIntent就是一个能够在满足一定条件下运行的Intent,它相比于Intent的优势在于自己携带有Context对象.这样他就不必依赖于某个activity才干够存在. 它和Intent的主要差别在于Intent的运行立马的,而pendingIntent的运行不是立马的.pendingIntent运行的操作实质上是參数传进来的Intent的操作.可是使用pendingIntent的目的在于它所包括的Intent的操作的运行是须要满足某些条件的. 二实质 PendingIn…
public void sendNotification(Context ctx,String message) { //get the notification manager String ns = Context.NOTIFICATION_SERVERS; NotificationManager nm = (Notification) ctx.getSystemService(ns); //create notification object includes icon ,text ,th…
PendingIntent PendingIntent它的直译是:待处理意图,这样翻译,大家就猜出它的作用是什么了,用于处理一些定义但是不立即使用的意图,最常见的就是用户点击通知,然后跳转指定的页面: 最常用的方法估计就下面这个了: public static PendingIntent getActivity (Context context, int requestCode, Intent intent, int flags) 类似的还有: PendingIntent.getActivity…
PendingIntent字面意义:等待的,未决定的Intent.要得到一个pendingIntent对象,使用方法类的静态方法 getActivity(Context, int, Intent, int),   getBroadcast(Context, int, Intent, int),   getService(Context, int, Intent, int)  分别对应着Intent的3个行为,跳转到一个activity组件.打开一个广播组件和打开一个服务组件. 参数有4个,比较重…
1, 构造intent Intent mIntent = new Intent("android.intent.action.MAIN"); ComponentName comp = new ComponentName( "com.mozillaonline.downloadprovider", "com.mozillaonline.downloadprovider.DownloadProviderActivity"); mIntent.setC…
Intent updateIntent = new Intent(GetNoticeService.this, DetailGonggaoActivity.class); updateIntent.putExtra("type", "weidu"); updateIntent.putExtra("title", (String) json.get("title")); updateIntent.putExtra("i…
数据发送方: public static void notify(Context context, TxrjMessage msg) {     NotificationManager notifiMgr = (NotificationManager) context             .getSystemService(Context.NOTIFICATION_SERVICE);     /*Notification notifi = new Notification(R.drawabl…
1. 连续发送两条信息时,出现bug.以下是bug现象描述. 发送第一条信息,sentReceiver弹出toast告知发送成功,同时在listview中的发送状态立即同步更新为发送成功. 继续发送第二条信息,sentReceiver也弹出toast告知发送成功,但是在listView中发送状态仍然是正在发送中. 在QQ通讯录中查看第二条信息,发现它的发送状态也是正在发送中,QQ通讯录已经将状态改为发送失败了. 再次试验,连续发送两条信息之后,第二条发送成功之后,它的发送状态没有改变为发送成功,…
情况是这样的,使用NotificationManager触发多个Notification: private Notification genreNotification(Context context, int icon, String tickerText, String title, String content, Intent intent){ Notification notification = new Notification(icon, tickerText, System.cur…