PendingIntent 传值 需注意,以及其四个flag常量

常用通知类型的消息

 long time=SystemClock.elapsedRealtime();
 MyLog.e("RingingActivity ",String.format(Locale.getDefault(), "onclick time = %s;", time));
 Intent i=new Intent(this,RingingActivity.class);
  Bundle b=new Bundle();
  b.putLong("t", time);
 i.putExtra("t", time);
 i.putExtra("b", b);
 Notification n=new Notification(R.drawable.ic_launcher, "看看notification里面的时间是否变化了", System.currentTimeMillis());
 PendingIntent pi=PendingIntent.getActivity(this, 0, i,
							PendingIntent.FLAG_UPDATE_CURRENT);
							// FLAG_UPDATE_CURRENT更新Intent;
							// FLAG_CANCEL_CURRENT;bu更新Pending;
							// FLAG_ONE_SHOT获取的PendingIntent只能使用一次,再使用PendingIntent也将失败
							// FLAG_NO_CREAT获取的PendingIntent若描述的Intent不存在则返回NULL值.
 n.setLatestEventInfo(this, "消息标题", "消息内容", pi);	
																														
 NotificationManager nm=(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
 nm.notify(88, n);

 

当intent 传值出现问题和还有一种情况:就是单例的Activity:OnNewIntent 不走OnCreate 这个方法


===================================================扩展,灵活的Notification创建============================================

后续添加,今天心情不好









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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值