andriod Notification area/drawer

来源:互联网 发布:矩阵的长度 编辑:程序博客网 时间:2024/05/20 00:38

如果在开发中有消息在不需要用户马上处理,可以使用通知,显示在系统上方的状态栏,主要有两部分:

标题、图标、内容等。

与toast不一样的消息提醒,主要包括更新、短消息等。

eg:

NotificationManager manager=(NotificationManager )this.getSystemService(Content.NOTIFICATION_SERVICE); //

manager.notify(id,notification);//发送一个通知

manager.concel(id);//取消一个通知

=============小试牛刀================

NotificationCompat.Builder builder=New NotificationCompat.Builder (this)

.setSmallIcon(R.Dwrable.图标)

. .setContentTitle(“标题”)

.setContentText(“”内容)

.setTicker("内容来了。。。。") //状态栏中显示的内容

.setXXXX(shezhi qita 其他); //叠加闪烁 声音 震动等

Notification notification=builder.build();

manager.notify()1,notification;