Подтвердить что ты не робот

Возможно ли установить расширенное уведомление по умолчанию в сообщениях с большим текстом?

Я последовал за этим Образцом кода

В разделе Big Text Notifications он сказал, что нужно расширить, чтобы увидеть форму Big text notification, как изображение im ниже:

enter image description here

Интересно, что мы не можем set Expanded Notification as default in Big Text Notifications?

Люди, которые это знают, могут или нет,

Если может,

Скажите, пожалуйста, как это сделать,

Спасибо,

4b9b3361

Ответ 1

Документация :

Большое вид уведомления появляется только тогда, когда уведомление расширенный, что происходит, когда уведомление находится в верхней части ящик уведомлений или когда пользователь расширяет уведомление с помощью жест.

Итак, мой ответ - нет, вы не можете его расширять по умолчанию.

Однако есть трюк, чтобы направить уведомление в верхнюю часть списка, где он будет расширен. Просто установите приоритет Notification.PRIORITY_MAX, и, скорее всего, ваше уведомление о приложении сделает его на вершине.

Ответ 2

Notification noti = new Notification.Builder()
... // The same notification properties as the others
.setStyle(new Notification.BigPictureStyle().bigPicture(mBitmap))
.build();

Вы меняете

.setStyle(new NotificationCompat.BigTextStyle().bigText(th_alert))

вместе с объявлением

notification = new NotificationCompat.Builder(context)

Вот пример:

введите описание изображения здесь Вы можете установить код

Intent intent = new Intent(context, ReserveStatusActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
NotificationManager notificationManager =
            (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
intent = new Intent(String.valueOf(PushActivity.class));
intent.putExtra("message", MESSAGE);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
stackBuilder.addParentStack(PushActivity.class);
stackBuilder.addNextIntent(intent);
// PendingIntent pendingIntent =
stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

// android.support.v4.app.NotificationCompat.BigTextStyle bigStyle = new     NotificationCompat.BigTextStyle();
// bigStyle.bigText((CharSequence) context);

notification = new NotificationCompat.Builder(context)
    .setSmallIcon(R.mipmap.ic_launcher)
    .setContentTitle(th_title)
    .setContentText(th_alert)
    .setAutoCancel(true)
 // .setStyle(new Notification.BigTextStyle().bigText(th_alert)  ตัวเก่า
 // .setStyle(new NotificationCompat.BigTextStyle().bigText(th_title))
    .setStyle(new NotificationCompat.BigTextStyle().bigText(th_alert))
    .setContentIntent(pendingIntent)
    .setNumber(++numMessages)
    .build();

notification.sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
notificationManager.notify(1000, notification);

Ответ 3

Не нужно делать какие-либо изменения в любом файле для отображения нескольких строк уведомления при использовании Push Notification V5, удалить поле "стиль" из отправляемого объекта. Автоматически отображаются несколько строк уведомления. Для получения дополнительной информации, повысьте ответ, задайте свой запрос. Я помогу вам.

Для справки посетите этот вопрос

Ответ 4

Из этого кода уведомления вы получаете изображения, а также большой текст или больше.

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);