How to apply a big view style to a notification using Parse library

前端 未结 8 865
孤街浪徒
孤街浪徒 2021-02-04 06:03

This library works perfectly, but i have a doubt.

When I send a message to users with more than two lines, users can\'t see all message in notification area.

But

8条回答
  •  走了就别回头了
    2021-02-04 06:45

    Here's an example using Notification.BigTextStyle.

        final String someLongText = "fkdljfdldkfj;ldaksjfkladj;flja;lkjdfljadslfjaddfdsfafjdfad" +
                "fdl;akjf;lkdf;lkaj;flkjda;lkfjadljflk;adsjfladjflk;dfjlkdjflakdfjdaffjdlfjdjjj" +
                "adjflkjadlkfjad;lkfjad;sljf;ladkjajlkfjad;lksfjl;akdjf;lkdsajf;lkdjfkadj;flkad" +
                "jf;lkadjfkldas;lkfja;dljf;lkdasjf;lkadjs;lfjas;ldkfj;lkadsjfl;kadljfl;kasdjf;l" +
                "jdlskfjklda;fjadslkfj;sdalkfj;ladjf;lajdl;fkajld;kfjlajfl;adjfl;kajdl;fjadl;kfj;";
    
        final Notification.Builder builder = new Notification.Builder(this);
        builder.setStyle(new Notification.BigTextStyle(builder)
                .bigText(someLongText)
                .setBigContentTitle("Big title")
                .setSummaryText("Big summary"))
                .setContentTitle("Title")
                .setContentText("Summary")
                .setSmallIcon(android.R.drawable.sym_def_app_icon);
    
        final NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        nm.notify(0, builder.build());
    

    Example

提交回复
热议问题