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…
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…
1.展示显示textTicker和仅仅有icon的两种情况:当參数showTicker为true时显示否则不显示 // In this sample, we'll use the same text for the ticker and the expanded notification CharSequence text = getText(textId); // choose the ticker text String tickerText = showTicker ? getString…
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 PendingIntent它的直译是:待处理意图,这样翻译,大家就猜出它的作用是什么了,用于处理一些定义但是不立即使用的意图,最常见的就是用户点击通知,然后跳转指定的页面: 最常用的方法估计就下面这个了: public static PendingIntent getActivity (Context context, int requestCode, Intent intent, int flags) 类似的还有: PendingIntent.getActivity…
情况是这样的,使用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…
MainActivity例如以下: package cc.cu; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.app.Activity; import android.app.Notification; import android.app.Notification…
通过AppWidget应用(一)的介绍,我们已经知道如何创建一个在主界面上显示一个appWidget窗口,但这并不是我们的目的,我们需要做到程序与用户之间进行交互:下面来介绍下如何通过appWidget启动一个Activity. 一.在appWidget的布局文件中添加一个按钮 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schema…
Android Notification 详解(一)--基本操作 版权声明:本文为博主原创文章,未经博主允许不得转载. 微博:厉圣杰 源码:AndroidDemo/Notification 文中如有纰漏,欢迎大家留言指出. 前几天项目中有用到 Android 通知相关的内容,索性把 Android Notification 相关的知识都看了一遍,稍作梳理,在此做个总结,以备不时之需. 温故而知新,可以为师矣~ 下图是我对 Notification 做的思维导图,也是本文的主要逻辑.  本文主要…