android通知栏Notification

 Notification是通过NotificationManager来处理的,功能包括:
  ·设置通知栏图标;
  ·设置通知栏标题;
  ·设置通知栏内容;
  ·设置点击通知栏activity的跳转;
  ·设置闪灯/LED;(收到短信或来电话时)
  ·设置铃声、震动等;
  
NotificationManager notiManage = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
  notiManage.notify(1, noti);

  
 noti哪来,请看:
 
Notification noti = new Notification();
 noti.icon = R.drawable.ic_launcher;
 noti.tickerText = "This is test!";
 noti.when = System.currentTimeMillis();  //这里是显示时:分,如22:43
 noti.setLatestEventInfo(this, noti.tickerText, "AAA", pendingIntent);  //将以上东西setView到Notification上去,要不然显示什么呀

 
 注:pendingIntent是个PendingIntent,看名字就知道,延迟的activity,指定义某一时间出现的Intent,当然你也可以设置为null。
 
Intent intent = new Intent(this, MainActivity.class);
 PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,intent, 0);

 
  我的博客其它文章列表
  http://my.oschina.net/helu
 
 

转载于:https://my.oschina.net/helu/blog/141728

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值