Android下添加状态栏图标的方法
来源:互联网 发布:怎么申请做淘宝模特 编辑:程序博客网 时间:2024/05/17 08:39
1.获得NotificationManager的引用
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager notificationManager =(NotificationManager)getApplicationContext().getSystemService(ns);
2.实例化Notification
int icon = R.drawable.send_sms;
CharSequence tickerText = “sending SMS”;
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText,when);
或者
Notification notification = new Notification();
notification .icon = R.drawable.send_sms;
notification.tickerText = “sending SMS”;
notification.defaults = Notification.DEAFULT_SOUND; //默认提示音
这一部分定义的信息都是显示在手机最上面的状态栏里面的。
3.定义Notification,如显示icon、目标intent等信息
Context context = getApplicationContext();
CharSequence contentTitle = “Registered SMS”;
CharSequence contentText = “send the registertion SMS to theCustomer Service”;
Intent notificationIntent = new Intent();
PendingIntent contentIntent = PendingIntent.getActivity(context, 0,notificationIntent, 0);
notification.setLatestEcentInfo(context, contentTitle, contentText,contentIntent);
这一部分定义的信息都是显示在下拉状态栏里面的,即状态窗口里面。
4.传递给NotificationManager
private static final int SALESTRACKER = 100;
notificationManager.notify(SALESTRACKER, notification);
6.取消Notification
notificationManager.cancel(SALESTRACKER);
0 0
- Android下添加状态栏图标的方法
- android 状态栏添加图标的函数
- android 状态栏添加图标的函数
- android状态栏右上角增加图标的方法
- Android 4.2 状态栏添加图标
- Android SystemUI状态栏添加图标
- Android SystemUI状态栏添加图标
- android添加常驻图标到状态栏
- android添加常驻图标到状态栏
- android添加常驻图标到状态栏
- android添加常驻图标到状态栏
- android添加常驻图标到状态栏
- VC添加状态栏的方法
- Android 软件的状态栏图标通知处理
- Android 软件的状态栏图标通知处理
- Android 5.0状态栏通知图标的实现
- iPhone 添加状态栏图标及自定义状态栏
- android下添加系统资源(图标)的问题
- 面试问题整理
- 浅谈JNI
- Android下CTS测试介绍
- Ubuntu12.4下手动安装jdk1.6
- 软件测试相关知识总结
- Android下添加状态栏图标的方法
- Android敏捷开发指南
- 单元测试工具及其优缺点对比
- Eclipse中android项目名前有红叉但…
- 迭代法剖析
- 背包问题
- Ubuntu下eclipse配置Hadoop教程(上)
- Ubuntu下eclipse配置Hadoop教程(下)
- 各大公司面试笔试题集锦(上)