`
蒋瑾珂
  • 浏览: 4289 次
  • 性别: Icon_minigender_2
  • 来自: 杭州
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

Android用户界面之notification(状态栏通知) (转)

 
阅读更多
主要标记有:

FLAG_UPDATE_CURRENT :如果已经存在PendingIntent,还产生该PendingIntent,还带有新的extra

FLAG_ONE_SHOT :这个PendingIntent只能被用一次。

FLAG_CANCEL_CURRENT:如果存在的PendingIntent还未消失,还取消将将要产生的该PendingIntent


主要代码:

String tickerText = shortText.getText().toString();   
String title = titleText.getText().toString();   
String content = contentText.getText().toString();   
  
//1、得到NotificationManager   
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);   
  
  
//2、实例化一个通知,指定了图标、概要、时间   
Notification notification = new Notification(Android.R.drawable.stat_notify_chat, tickerText, System.currentTimeMillis());   
  
//3、指定通知的标题、内容和intent   
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:104040444"));   
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);   
notification.setLatestEventInfo(this, title, content, pendingIntent);   
  
//指定标志和声音   
notification.flags = Notification.FLAG_AUTO_CANCEL;   
notification.defaults = Notification.DEFAULT_SOUND;   
  
//可以指定为震动,也可以用 .sound来自己指定声音   
//notification.defaults = Notification.DEFAULT_VIBRATE;   
  
//可以指定为闪光灯   
//notification.defaults = Notification.DEFAULT_LIGHTS;   
  
//4、发送通知给通知管理者   
manager.notify(1, notification); 

本篇文章来源于 Linux公社网站(www.linuxidc.com)  原文链接:http://www.linuxidc.com/Linux/2011-04/35100p2.htm
分享到:
评论

相关推荐

    android 通知栏 工具类

    通知是一个可以在应用程序正常的用户界面之外显示给用户的消息。 通知发出时,它首先出现在状态栏的通知区域中,用户打开通知抽屉可查看通知详情。通知区域和通知抽屉都是用户可以随时查看的系统控制区域。

    android开发揭秘PDF

    4.2.21 状态栏提示(Notification、NotificationManager) 4.2.22 对话框中的进度条(ProgressDialog) 4.3 界面布局 4.3.1 垂直线性布局 4.3.2 水平线性布局 4.3.3.相对布局(RelativeLayout) 4.3.4 表单布局...

    android开发demo集合

    19、Notification 状态栏通知 20、GridView、ImageSwitcher 21、SmsManager 消息管理器,发短信(这里是模拟器只能给其它模拟器发短信) 22、Intent Action、Category属性 测试 23、系统 Action、Category属性 24...

    《Android应用开发揭秘》附带光盘代码.

     4.2.21 状态栏提示(Notification、NotificationManager)  4.2.22 对话框中的进度条(ProgressDialog)  4.3 界面布局  4.3.1 垂直线性布局  4.3.2 水平线性布局  4.3.3.相对布局(RelativeLayout)  4.3.4 表单...

    android初学者入门项目

    19、Notification 状态栏通知 20、GridView、ImageSwitcher 21、SmsManager 消息管理器,发短信(这里是模拟器只能给其它模拟器发短信) 22、Intent Action、Category属性 测试 23、系统 Action、Category属性 24...

    Android应用开发揭秘pdf高清版

    4.2.21 状态栏提示(Notification、NotificationManager) 4.2.22 对话框中的进度条(ProgressDialog) 4.3 界面布局 4.3.1 垂直线性布局 4.3.2 水平线性布局 4.3.3.相对布局(RelativeLayout) 4.3.4 表单布局...

    《Android应用开发揭秘》源码

     4.2.21 状态栏提示(Notification、NotificationManager)  4.2.22 对话框中的进度条(ProgressDialog)  4.3 界面布局  4.3.1 垂直线性布局  4.3.2 水平线性布局  4.3.3.相对布局(RelativeLayout)  4.3.4 表单...

    新版Android开发教程.rar

    ----------------------------------- Android 编程基础 1 封面----------------------------------- Android 编程基础 2 开放手机联盟 --Open --Open --Open --Open Handset Handset Handset Handset Alliance ...

    《Google Android SDK开发范例大全(第3版)》.pdf

    5.8 状态栏的图标与文字提醒 200 5.9 搜索手机通讯录自动完成 203 5.10 取得联系人资料 207 5.11 制作有图标的文件资源管理器 210 5.12 还原手机默认桌面 215 5.13 置换手机后台图 217 5.14 获取...

    Google Android SDK开发范例大全(第3版) 1/5

    5.8 状态栏的图标与文字提醒 5.9 搜索手机通讯录自动完成 5.10 取得联系人资料 5.11 制作有图标的文件资源管理器 5.12 还原手机默认桌面 5.13 置换手机后台图 5.14 获取手机现存桌面 5.15 文件资源管理器再进化 5.16...

    Google Android SDK开发范例大全(PDF高清完整版1)(4-1)

    5.8 状态栏的图标与文字提醒——NotificationManager与Notification对象的应用 5.9 搜索手机通讯录自动完成——使用ContentResolver 5.10 取得联系人资料——Provider.Contact的使用 5.11 制作有图标的文件资源管理...

    Google Android SDK开发范例大全(第3版) 4/5

    5.8 状态栏的图标与文字提醒 5.9 搜索手机通讯录自动完成 5.10 取得联系人资料 5.11 制作有图标的文件资源管理器 5.12 还原手机默认桌面 5.13 置换手机后台图 5.14 获取手机现存桌面 5.15 文件资源管理器再进化 5.16...

    Google Android SDK开发范例大全(PDF完整版4)(4-4)

    5.8 状态栏的图标与文字提醒——NotificationManager与Notification对象的应用 5.9 搜索手机通讯录自动完成——使用ContentResolver 5.10 取得联系人资料——Provider.Contact的使用 5.11 制作有图标的文件资源管理...

    Google Android SDK开发范例大全(第3版)part2

     5.8 状态栏的图标与文字提醒  5.9 搜索手机通讯录自动完成  5.10 取得联系人资料  5.11 制作有图标的文件资源管理器  5.12 还原手机默认桌面  5.13 置换手机后台图  5.14 获取手机现存桌面  5.15 ...

    Google Android SDK开发范例大全(第3版) 3/5

    5.8 状态栏的图标与文字提醒 5.9 搜索手机通讯录自动完成 5.10 取得联系人资料 5.11 制作有图标的文件资源管理器 5.12 还原手机默认桌面 5.13 置换手机后台图 5.14 获取手机现存桌面 5.15 文件资源管理器再进化 5.16...

    Google Android SDK开发范例大全(第3版) 5/5

    5.8 状态栏的图标与文字提醒 5.9 搜索手机通讯录自动完成 5.10 取得联系人资料 5.11 制作有图标的文件资源管理器 5.12 还原手机默认桌面 5.13 置换手机后台图 5.14 获取手机现存桌面 5.15 文件资源管理器再进化 5.16...

Global site tag (gtag.js) - Google Analytics