android中创建通知栏Notification代码实例
/////第一步:获取NotificationManager
NotificationManagernm=(NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
/////第二步:定义Notification
Intentintent=newIntent(this,OtherActivity.class);
//PendingIntent是待执行的Intent
PendingIntentpi=PendingIntent.getActivity(this,0,intent,
PendingIntent.FLAG_CANCEL_CURRENT);
Notificationnotification=newNotification.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);热门推荐
10 感谢韩语老师祝福语简短
11 升职文案高级祝福语简短
12 花童结婚祝福语大全简短
13 向国庆送祝福语简短
14 什么寄语简短祝福语女生
15 客户回礼祝福语大全简短
16 女孩生日祝福语简短创意
17 家长回复节日祝福语简短
18 给外婆敬酒祝福语简短