如何使用像WhatsApp这样的概述实现Android Notification?

时间:2016-01-27 17:16:14

标签: android notifications

我希望在设备使用时像概述 实施通知,例如WhatsApp:

enter image description here

我通过这种方式了解基本实现:

PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, 
    new Intent(this, MainActivity.class), 0);

Notification notification = new Notification.Builder(this)
                .setContentTitle("Title")
                .setContentText("Message")
                .setSmallIcon(R.drawable.ic_notif)
                .setContentIntent(mPendingIntent)
                .build();

NotificationManager notificationManager = 
    (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(1, notification);

但在那种情况下,我没有概述。我在通知栏中只有一个小图标:

Simple Notification

1 个答案:

答案 0 :(得分:1)

最后,它只是优先级

notificationBuilder.setPriority(Notification.PRIORITY_HIGH);