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…
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相信大家都不陌生了,平时上QQ的时候有消息来了或者有收到了短信,手机顶部就会显示有新消息什么的,就类似这种.今天就稍微记录下几种Notification的用法.3.0以前的通知和3.0以后的通知是有些区别的.话不多说,直接上代码. 1.新建一个android项目 我新建项目的 minSdkVersion="11",targetSdkVersion="19".也就是支持最低版本的3.0的. 2.习惯性地打开项目清单文件AndroidMa…
我们知道在使用Android的通知的时候一定会用到NotificationManager . Notification这两个类,这两个类的作用分别是: NotificationManager :  是状态栏通知的管理类,负责发通知.清楚通知等. Notification:状态栏通知对象,可以设置icon.文字.提示声音.振动等等参数. 这里需要声明一点,由于Android的系统升级,Android在通知这块也有很多老的东西被抛弃了,一个是api11的版本,一个是api16的版本.我们来比较下ap…
Notification和NotificationManager 1.Broadcast Receiver组件没有提供可视化的界面来显示广播信息.这里我们可以使用Notification和NotificationManager来实现可视化的信息显示.通过使用它们我们可以显示广播信息的内容,图标 以及震动等信息. 2.使用Notification和NotificationManager也比较简单,一般获得系统级的服务NotificationManager,然后实例化Notification,设置其…
常用的程序通知,显示到主页面的顶部栏. package com.lixu.tongzhi; import android.app.Activity; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Intent; import android.os.Bundle; import andr…
1.什么是RemoteView? 答:其实就是一种特殊的view结构,这种view 能够跨进程传输.并且这种remoteview 还提供了一些方法 可以跨进程更新界面.具体在android里面 一个是通知 一个是桌面小部件. 这2个就是remoteview 最直接的应用了 2.RemoteView在通知上的应用? 答:这里给出一个小例子,比较粗糙 仅做演示使用. //默认样式的notification private void normalStyleNotification() { Intent…
一个简单的应用场景:假如用户打开Activity以后,按Home键,此时Activity 进入-> onPause() -> onStop() 不可见.代码在此时机发送一个Notification到通知栏.当用户点击通知栏的Notification后,又重新onRestart() -> onStart() -> onResume() 切换回原Activity. package com.zzw.testnotification; import android.app.Activity…
首先要明白一个概念: Intent 与 PendingIntent 的区别: Intent:是意图,即告诉系统我要干什么,然后做Intent应该做的事,而intent是消息的内容 PendingIntent 为Intent的包装,这里是启动Intent的描述,PendingIntent.getActivity 返回的PendingIntent表示,此PendingIntent实例中的Intent是用于启动 Activity 的Intent.PendingIntent.getActivity的参数…