Is possible set Expanded Notification as default in Big Text Notifications?

后端 未结 5 970
陌清茗
陌清茗 2020-12-05 06:27

I followed this Sample Code

In Big Text Notifications section, he said that need expand to see Big text notification form, as image im belo

5条回答
  •  情书的邮戳
    2020-12-05 07:03

    From this notification code you have got images, and big text or more.

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context);
                if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                    mBuilder.setSmallIcon(R.drawable.small_logo);
                    mBuilder.setColor(Color.parseColor("#D74F4F"));
                } else {
                    mBuilder.setSmallIcon(icon);
                }
    
                mBuilder.setTicker(title).setWhen(when);
                mBuilder.setAutoCancel(true);
                mBuilder.setContentTitle(title);
                mBuilder.setContentIntent(intent);
                mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
                mBuilder.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), icon));
                mBuilder.setContentText(msg);
                mBuilder.setPriority(Notification.PRIORITY_MAX);
                if (Utils.validateString(banner_path)) {
                    mBuilder.setStyle(notiStyle);
                } else {
                    mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(msg));
                }
    
                Notification noti = mBuilder.build();
                notificationManager.notify(0, noti);
    

提交回复
热议问题