为什么我的InboxStyle通知看起来与常规通知相同?

时间:2014-12-04 18:51:59

标签: android android-5.0-lollipop

我有以下方法发布通知,但是没有应用任何inboxStyle内容 - 结果通知与该代码不存在完全相同

    public void postMultilineNotification(View view) {
        Notification.Builder builder = new Notification.Builder(this);
        builder.setPriority(Notification.PRIORITY_HIGH);
        builder.setDefaults(Notification.DEFAULT_VIBRATE);
        builder.setContentText("Content text");
        builder.setSmallIcon(R.drawable.ic_launcher);
        builder.setContentTitle("Supposed to be multi line");
        builder.setColor(0xff006699);

        builder.addAction(ic_call_white_24dp, "1", null);
        builder.addAction(ic_call_white_24dp, "2", null);
        builder.addAction(ic_call_white_24dp, "3", null);


/ ** the following 6 lines make no visible difference to the posted notification  */
        Notification.InboxStyle inboxStyle =  new Notification.InboxStyle();
        inboxStyle.setBigContentTitle("Big Content Title");
        inboxStyle.addLine("Line 1");
        inboxStyle.addLine("Line 2");
        inboxStyle.addLine("Line 3");
        builder.setStyle(inboxStyle);


        Notification notification = builder.build();
        NotificationManager notificationManager =
                (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        notificationManager.notify(4, notification);
    }

0 个答案:

没有答案