现在的位置: 首页 > 综合 > 正文

android Notification 学习

2012年12月29日 ⁄ 综合 ⁄ 共 752字 ⁄ 字号 评论关闭
 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);









  

抱歉!评论已关闭.