android Notification 学习

本文详细介绍了如何在Android中创建并显示一个系统通知。通过具体的代码示例,展示了设置通知的各种属性,包括图标、声音、取消方式、提示文本等,并解释了如何使用Intent和PendingIntent来处理点击通知后的跳转动作。
复制代码
 1             Notification notification = new Notification(com.android.internal.R.drawable.stat_sys_warning,"notification.",System.currentTimeMillis());
2 notification.defaults = Notification.DEFAULT_SOUND;
3 notification.flags = Notification.FLAG_AUTO_CANCEL;
4 notification.tickerText="miss sdCard";
5 NotificationManager notificationManager = (NotificationManager)mContext.getSystemService(Context.NOTIFICATION_SERVICE);
6
7 Intent mIntent = new Intent();
8 mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
9 PendingIntent mContentIntent =PendingIntent.getActivity(mContext,0, mIntent, 0);  
        //这里必需要用setLatestEventInfo(上下文,标题,内容,PendingIntent)不然会报错.10           
        notification.setLatestEventInfo(mContext, "10086", "holle, merci.", mContentIntent); 11 
12
13 notificationManager.notify(0, notification);



本文转自wanqi博客园博客,原文链接http://www.cnblogs.com/wanqieddy/archive/2011/08/11/2134941.html:如需转载请自行联系原作者




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值