android开发分享android中创建通知栏Notification代码实例

///// 第一步:获取notificationmanager notificationmanager nm = (notificationmanager)

  ///// 第一步:获取notificationmanager  		notificationmanager nm = (notificationmanager)   				getsystemservice(context.notification_service);    		///// 第二步:定义notification  		intent intent = new intent(this, otheractivity.class);  		//pendingintent是待执行的intent  		pendingintent pi = pendingintent.getactivity(this, 0, intent,  				pendingintent.flag_cancel_current);  		notification notification = new notification.builder(this)  				.setcontenttitle("title")  				.setcontenttext("text")  				.setsmallicon(r.drawable.ic_launcher).setcontentintent(pi)  				.build();  		notification.flags = notification.flag_no_clear;  		  		/////第三步:启动通知栏,第一个参数是一个通知的唯一标识  		nm.notify(0, notification);  		  		//关闭通知  		//nm.cancel(0);

上述就是android开发分享android中创建通知栏Notification代码实例的全部内容,如果对大家有所用处且需要了解更多关于Android学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/addevelopment/941079.html

(0)
上一篇 2021年11月14日
下一篇 2021年11月14日

精彩推荐