当前位置: 移动技术网 > IT编程>移动开发>Android > Android Notification使用方法详解

Android Notification使用方法详解

2019年07月24日  | 移动技术网IT编程  | 我要评论

营山中学,青春不败101119,h漫画图

android  notification使用详解

notification

核心代码(链式调用):适用于android 4.0以上(不兼容低版本)

notification noti = new notification.builder(this)
.setcontenttitle("标题名称")
.setcontenttext("标题里的内容")
.setsmallicon(r.drawable.new_mail)
.setlargeicon(bitmapfactory.decordresource(getresources(), r.drawable.ic_launcher))
.build();

notificationmanager nm = (notificationmanager) getsystemservice(notification_service);
nm.notify(0, noti);

兼容版本

notification notification = new notification(r.drawable.ic_launcher, "xxxxxx", system.currenttimemillis());
//点击事件真正想执行的动作
intent intent = new intent();
intent.setaction(intent.action_dial);
intent.setdata(uri.parse("tel:110"));
pendingintent contentintent = pendingintent.getactivity(this, 0, intent, pendingintent.flag_update_current);
notification.setlatesteventinfo(this, "标题", "内容", contentintent);
notificationmanager nm = (notificationmanager) getsystemmanager(notification_service);
nm.notify(0, notification);

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网