Notification Builder的所有设置

此builder为API16后方可使用:

<pre name="code" class="java">		PendingIntent intent = PendingIntent.getActivity(this, 0, new Intent(this,MainActivity.class), 0);
		notification = new Notification.Builder(this)
//				.addAction(icon, "拉下后的标题", intent)//在这条通知下面添加一个icon图标button,点击触发事件,例如 phone的挂断
				.setContentTitle("拉下后的标题")
				.setContentText("第一行内容")
//				.setContent(RemoteViews)//自定义的remoteviews
//				.setFullScreenIntent(p, true)//不会再通知栏直接显示,但拉下后可以显示内容 Only for use with extremely high-priority notifications demanding the user's immediate attention, such as an incoming phone call or alarm clock that the user has explicitly set to a particular time.
//				.setDeleteIntent(null)// 通知消失时的动作
//				.setContentIntent(p)//点击的动作 相当于点击button
//				.setLights(new Color().BLACK, 1000, 1000)//俺的手机不支持..无反应
//				.setNumber(22)// 
//				.setOngoing(true)//不能被用户x掉,会一直显示,如音乐播放等
//				.setPriority(2)//优先级
//				.setProgress(max, progress, indeterminate)//进度条  
//				.setSound(uri)//声音提示
//				.setSound(sound, streamType)//科设置 streamtype
//				.setStyle(style)//style设置 http://developer.android.com/reference/android/app/Notification.Style.html
//				.setVibrate(long[])//设置震动
				.setOnlyAlertOnce(true)//一次而已
				.setSmallIcon(R.drawable.page)//落下前显示的图标
				.setSubText("第二行内容"+"\n"+"!!!!!!!!!!")
				.setContentInfo("额外的内容")//添加到了右下角
//				.setShowWhen(true)//是否允许setwhen
				.setWhen(System.currentTimeMillis()+300)//何时通知 这里延迟了300ms,前提设置了setshowwher
				.setTicker("直接在标题栏显示的通知", null)
				.setLargeIcon(
						BitmapFactory.decodeResource(getResources(),
								R.drawable.ic_launcher))//落下后显示的图标
				.build();//生成实例 api 16后不再使用getNotification()
mNotificationManager.notify(R.drawable.ic_launcher, notification);



                
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值