Android Notification使用方法详解
程序员文章站
2023-12-13 12:16:10
android notification使用详解
notification
核心代码(链式调用):适用于android 4.0以上(不兼容低版本)...
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);
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!