Android 通知栏消息
来源:互联网 发布:cain破解mysql 编辑:程序博客网 时间:2024/05/18 03:32
可以用Activity和Service来开始消息通知,两者的区别在于一个是在前台触发,一个是后台服务触发。
要使用消息通知,必须要用到两个类:NotificationManager和Notification,其他NotificationManager的初始化是用getSystemService方法,并且通过notify方法来向android系统发送消息栏通知和显示。
代码:
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);//定义通知栏展现的内容信息 int icon = R.drawable.ic_launcher; CharSequence tickerText = "我的通知栏标题"; long when = System.currentTimeMillis(); Notification notification = new Notification(icon, tickerText, when); //定义下拉通知栏时要展现的内容信息 Context context = getApplicationContext(); CharSequence contentTitle = "我的通知栏标展开标题"; CharSequence contentText = "我的通知栏展开详细内容"; Intent notificationIntent = new Intent(this, BootStartDemo.class); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); //用mNotificationManager的notify方法通知用户生成标题栏消息通知 mNotificationManager.notify(1, notification);
0 0
- Android 通知栏消息
- Android 通知栏消息
- android 通知栏消息
- android通知栏区分多通知消息
- android通知栏的消息通知(Notification)
- Android消息通知栏应用
- android的消息通知栏
- Android消息通知栏开发
- Android显示通知栏消息
- Android Notification通知栏消息
- Android发送通知栏消息
- Android发送通知栏消息
- Android 通知栏推送消息
- Android通知栏消息(基本文字通知)
- 实现Android的消息通知栏
- android开发之Notification_通知栏消息
- 实现Android的消息通知栏
- android开发之Notification_通知栏消息
- EntityFramework走马观花之CRUD(上)
- Struts2 OGNL表达式
- 上海华为的一道关于指针方面的编程题 int A[nSize],其中隐藏着若干0,其余非0整数,写一个函数int Func(int* A, int nSize)
- CSV读取和写入
- 美图秀秀2014电脑版 v3.9.6.1003 官方最新版
- Android 通知栏消息
- 美团已露王者气:是时候砸广告了!
- WinRAR美化增强版 v5.10 简体中文版
- ubuntu12.04 64位txt中文乱码问题
- q讯家园看加密空间 官方免费版
- 关系型数据库与HBase的数据储存方式区别
- Call-time pass-by-reference has been removed
- 福禄滋味
- 15位和18位身份证JS校验实例(jquery)和注意项