Notification使用举例
来源:互联网 发布:韩国人听歌用什么软件 编辑:程序博客网 时间:2024/06/05 10:55
<ul style="margin-top: 0px; margin-bottom: 0px; font-family: 微软雅黑; font-size: 14px; line-height: 21px;"><li style="background-color: inherit;"><span style="background-color: inherit; color: rgb(0, 112, 192); font-family: 宋体; font-size: 12pt;">创建一个<span style="font-family:Calibri;background-color: inherit;">Notification</span><span style="font-family:宋体;background-color: inherit;">的步骤。</span></span></li></ul><p style="margin-top: 5px; margin-bottom: 5px; font-family: 微软雅黑; font-size: 14px; line-height: 21px;"><span style="background-color: inherit; color: rgb(0, 112, 192); font-family: 宋体; font-size: 12pt;">思路:①得到<span style="font-family:Calibri;background-color: inherit;">NotificationManager</span><span style="font-family:宋体;background-color: inherit;">的引用;②初始化一个</span><span style="font-family:Calibri;background-color: inherit;">Notification</span><span style="font-family:宋体;background-color: inherit;">对象;③设置</span><span style="font-family:Calibri;background-color: inherit;">Notification</span><span style="font-family:宋体;background-color: inherit;">的参数;④使用</span><span style="font-family:Calibri;background-color: inherit;">NotificationManager</span><span style="font-family:宋体;background-color: inherit;">的</span><span style="font-family:Calibri;background-color: inherit;">notify(int, Notification)</span><span style="font-family:宋体;background-color: inherit;">方法发出通知。</span></span></p>
<span style="font-size:18px;">public void initNotifi() {String ns = Context.NOTIFICATION_SERVICE;</span>
<span style="font-size:18px;"><span style="white-space:pre"></span><strong>//得到NotificationManager的引用</strong>mNotificationManager = (NotificationManager) getActivity().getSystemService(ns);<span style="white-space:pre"><strong></strong></span><strong>//初始化一个Notification对象,并设置参数,闪灯、声音、icon</strong>notification = new Notification();notification.defaults |= Notification.DEFAULT_SOUND;notification.defaults |= Notification.DEFAULT_LIGHTS;notification.icon = R.drawable.shop;notification.when = System.currentTimeMillis();context = getActivity().getApplicationContext();contentTitle = "简付";contentText = "买单成功,点击查看!";}</span>
<span style="font-size:18px;">public void onClick(View v) {switch (v.getId()) {case R.id.bt_maidanimdia:<strong>//<span style="color: rgb(0, 112, 192); font-family: 宋体; font-size: 16px; line-height: 21px; white-space: pre; background-color: inherit;">使用</span><span style="color: rgb(0, 112, 192); font-size: 16px; line-height: 21px; white-space: pre; font-family: Calibri; background-color: inherit;">NotificationManager</span><span style="color: rgb(0, 112, 192); font-family: 宋体; font-size: 16px; line-height: 21px; white-space: pre; background-color: inherit;">的</span><span style="color: rgb(0, 112, 192); font-size: 16px; line-height: 21px; white-space: pre; font-family: Calibri; background-color: inherit;">notify(int, Notification)</span><span style="color: rgb(0, 112, 192); font-family: 宋体; font-size: 16px; line-height: 21px; white-space: pre; background-color: inherit;">方法发出通知。</span></strong>Intent notificationIntent = new Intent(getActivity(),CardTxnDetailsActivity.class);contentIntent = PendingIntent.getActivity(getActivity(), 0,notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);notification.setLatestEventInfo(context, contentTitle, contentText,contentIntent);mNotificationManager.notify(MAIDAN_ID, <strong>notification</strong>);getActivity().finish();break;</span>
0 0
- Notification使用举例
- Notification 使用
- Notification使用
- 使用Notification
- Notification 使用
- notification 使用
- Notification使用
- Notification使用
- 使用Notification
- notification使用
- Notification举例——简单程序
- Notification---Notification使用详解之一:基础应用
- Notification的使用(自定义Notification布局)
- 使用 WS-Notification
- 3. Notification的使用
- 3、Notification的使用
- Android-Notification的使用
- Android NOtification 使用
- 羇膀薃螂膃膆薃羅肆蒄薂蚄
- 莆羅肀肇薅螅肃膃蚄蚄肅艿
- 达内培训第三天笔记
- 肂蒅蚄肅羈蒅螇袈芆蒄薆肃
- 衿肄蒃羁膁肆蕿蚇肀蒂蚅袆
- Notification使用举例
- 螅肄蒄螀螄膆芇蚆袃艿蒃薂
- 螂膁膇蒆螅袅莆蝿蚇袀膂薈
- 肆蒇螂袇腿芀蚈袆莁蒅蚄袅
- AngularJs学习笔记--bootstrap
- 袂芀薀袈羈肆荿螀羄膅艿螃
- 莄虿螄肆蕿薅螃膈莂蒁螂芀
- 蚀罿芇螀袈芁膀螆肇肁薅葿
- DIY字符串比较函数