Android简单的消息通知栏
来源:互联网 发布:软件部署 编辑:程序博客网 时间:2024/04/30 18:27
一.直接代码
package com.zhc.notificaiton;import android.os.Bundle;import android.app.Activity;import android.app.Notification;import android.app.NotificationManager;import android.app.PendingIntent;import android.content.Context;import android.content.Intent;import android.view.Menu;public class MainActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);//消息通知栏//定义NotificationManagerString ns = Context.NOTIFICATION_SERVICE;NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);//定义通知栏展现的内容信息int icon = R.drawable.ic_launcher;CharSequence tickerText = "我的通知栏标题";long when = System.currentTimeMillis();Notification notification = new Notification(icon, tickerText, when);//定义下拉通知栏时要展现的内容信息Context context = getApplicationContext();CharSequence contentTitle = "检测到新的OTA版本!";CharSequence contentText = "是否需要安装新的OTA版本";//System.out.println("ningc----MainActivity----uri "+mPrefs.getDownloadURL());//TODOIntent notificationIntent = new Intent(getApplicationContext(), MainActivity.class);PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0,notificationIntent, 0);notification.setLatestEventInfo(context, contentTitle, contentText,contentIntent);//用mNotificationManager的notify方法通知用户生成标题栏消息通知mNotificationManager.notify(1, notification);}}
二.效果图
三,功能更加全面的消息通知栏
1》http://blog.csdn.net/vipzjyno1/article/details/25248021/
2》http://mp.weixin.qq.com/s?__biz=MzA5MzI3NjE2MA==&mid=2650235923&idx=1&sn=af1fc1a6b60282732d94b0e7a354488f&scene=1&srcid=0517c0t12GnMgc5tWAkEMHNs#
0 0
- Android简单的消息通知栏
- android通知栏的消息通知(Notification)
- android的消息通知栏
- Android 通知栏消息
- Android 通知栏消息
- android 通知栏消息
- 实现Android的消息通知栏
- 实现Android的消息通知栏
- 实现Android的消息通知栏
- 实现Android的消息通知栏
- 实现Android的消息通知栏
- Android应用消息通知栏的实现
- android通知栏区分多通知消息
- Android的消息通知--Notification
- Android的消息通知--Notification
- 简单的Android通知
- Android消息通知栏应用
- Android消息通知栏开发
- android设计 实现窗体启动时,显示一个水平进度条,当进行完成后,隐藏该进度条,并显示一张图 片。
- 微信JS SDK Demo
- Spring Bean Validation
- 解决"无法在windows资源管理器中查看此FTP站点
- redis原理及安装配置
- Android简单的消息通知栏
- bzoj 2257: [Jsoi2009]瓶子和燃料 裴蜀定理
- mysql的主从复制
- 【codevs 2744】养鱼喂妹纸
- 修改表为只读状态
- js-局部变量+全局变量+闭包
- hdu 2059 加油站(dp)
- 堆排序算法代码
- MySQL中重复索引和重复外键清理