文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > 计算机软件及应用 > Android 用户界面---通知(Notifications)
侵权投诉

Android 用户界面---通知(Notifications)

Intent[] stack = IncomingMessage.makeMessageIntentStack(this, from, msg);

startActivities(stack);

finish();

}

管理通知

NotificationManager是管理所有通知的一个系统服务。必须用getSystemService()方法获取这个对象的引用,如:

String ns = Context.NOTIFICATION_SERVICE;

NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);

当你想要给状态栏发送通知时,就要使用NotificatonManager对象的notify(int, Notification)方法,第一个参数是通知的唯一ID,第二个参数是Notification对象。这ID唯一标识了从你的应用程序中发出通知,如果要更新通知或者(应用管理了不同类型的通知)通过通知中定义的Intent对象返回应用程序时,就需要这个ID。

把“FLAG_AUTO_CANCEL”标记添加给Notification对象,用户从通知窗口选择了通知后,就会清除状态栏通知。也可以用cancle(int)方法来手动的清除,或者用cancelAll()方法清除所有的通知。

创建通知

Notification对象定义了显示在状态栏和通知窗口中的通知消息的细节,以及一些提醒设置,如声音,闪烁等。

以下是状态栏通知的所有需求:

1. 一个状态栏图标;

2. 除非你定义了一个定制的通知布局,否则就需要一个标题和消息内容;

3. 在通知被选择时,要触发一个PendingIntent对象。

以下是状态栏通知的可选设置:

1. 针对状态栏的一个提醒文本消息;

2. 一个提示音;

3. 一个震动设置;

4. 一个LED的闪烁设置。

启动一个新的通知的工具包括Notification(int, CharSequence, long)构造器和setLatestEventInfo(Context, CharSequence, CharSequence,PendingIntent)方法。它们能够定义通知设置的所有需求。下列代码片段演示了基本的通知安装步骤:

int icon = R.drawable.notification_icon; // icon from resources

CharSequence tickerText = "Hello"; // ticker-text

long when = System.currentTimeMillis(); // notification time

Context context = getApplicationContext(); // application Context

CharSequence contentTitle = "My notification"; // message title

CharSequence contentText = "Hello World!"; // message text

Intent notificationIntent = new Intent(this, MyClass.class);

PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

上一页第12页

你可能喜欢

热门文档

相关文档

  • ...用户界面 - 状态通知 - Status Notifications

    【Android开发API】用户界面 - 状态通知 - Status Notifications_计算机软件及应用_IT/计算机_专业资料。 eoe 移动开发者社区 www.eoe.cn 负责?:Kobehonghai 原文...

  • ...用户界面 - Toast通知 - Toast Notifications

    【Android开发API】用户界面 - Toast通知 - Toast Notifications_计算机软件及应用_IT/计算机_专业资料。eoe 移动开发者社区 www.eoe.cn 原文链接:http://...

  • 【Android开发Design】通知 - Notifications 1

    【Android开发Design】通知 - Notifications 1_制度/规范_工作范文_应用文书。... 要让产品有好的用户体验... 能让UI设计显得更简约的... 马桶到删除:从...

  • android用户界面程序设计

    android用户界面程序设计_IT/计算机_专业资料。淮海工学院计算机工程学院 实验...(可参考文档中 Dev Guide 的帮助主题 Toast Notifications 中的内容) 三、实验...

  • Android用户界面详解

    这个章节描述怎么实现一个基本的 Android 界面.它涉及构建屏幕基本元素,怎么在 xml(定义文件)内定义屏幕, 用你的代码生成, 在不同任务你需要操作你的用户接口. ...

  • Android用户界面

    Android用户界面框架 ? MVC模型 ? ? MVC模型中的控制器能够接受并响应程序的外部动作, 如按键动作或触摸屏动作等 控制器使用队列处理外部动作,每个外部动作作为一...

  • 第3章-Android图形用户界面设计

    图形用户界面设计 目标学员: 学习目标: Android初级开发者用户界面设计原则 用户界面设计核心概念 对话框 菜单 通知 课程时长: 4学时,180分钟 课程目录 1 2 3 4...

  • ...界面UI元素之对话框(Dialog)和通知(Notification)

    9.Android用户界面UI元素之对话框(Dialog)和通知(Notification)_IT/计算机_专业资料。Android开发教程Softeem Consultancy Service Android用户界面(UI)组件 用户界面( ...

  • android学习之界面UI小结

    ? ? ? ? User Interface(用户界面) View Hierarchy(视图层次) How Android ...(风格与主题) Notifications(通知) ActionBar(活动栏) Drag and Drop(拖拽) ...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email