Извините за поздний ответ. Фактически, я также столкнулся с той же проблемой и получил решение, поэтому я думаю, что он может помочь другому пользователю.
как мы не можем использовать оба BigTextStyle
и BigPictureStyle
метод NotificationCompat.Builder
, чем мы можем создать CustomView
.
Мы можем использовать setCustomBigContentView(RemoteViews)
метод NotificationCompat.Builder
и создать наш собственный просмотр, чтобы показать большое изображение с большим текстом.
Пожалуйста, проверьте ниже код для него: -
PendingIntent pendingIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), i,
PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this);
notificationBuilder.setContentTitle("YOUR_APP_NAME");
notificationBuilder.setContentText(body);
notificationBuilder.setTicker("YOUR_APP_NAME");
notificationBuilder.setAutoCancel(true);
notificationBuilder.setSound(defaultSoundUri);
notificationBuilder.setCustomBigContentView(remoteView("YOUR_MESSAGE_TO_SHOW"));///IT IS THE MAIN METHOD WHICH WE USE TO INFLATE OR CREATE THE CUSTOM VIEW
notificationBuilder.setSmallIcon(getNotificationIcon(notificationBuilder));
notificationBuilder.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify((int) System.currentTimeMillis(), notificationBuilder.build());
Ниже в RemoteViews, который мы назвали из нашего setCustomBigContentView()
метода
private RemoteViews remoteView(String message)
{
RemoteViews views;
views = new RemoteViews(getPackageName(), R.layout.YOUR_LAYOUT_HERE);
views.setImageViewBitmap(R.id.YOUR_BIG_IMAGE_ID_FROM_LAYOUT, bitmap);
views.setImageViewBitmap(R.id.YOUR_APP_ID_FROM_LAYOUT, BitmapFactory.decodeResource(getResources(), R.drawable.APP_ICON_OF_YOUR_APP));
views.setTextViewText(R.id.YOUR_BIG_TEXTVIEW_ID_FROM_LAYOUT, message);
return views;
}
я создал настраиваемое уведомление, как это
любое обновление по этой теме ?? с помощью BigPictureStyle с BigTextStyle ... –
Да, это довольно легко. Создайте свой собственный макет уведомлений! Вы можете создать свой xml и добавить его в уведомление. Для получения дополнительной информации: http://developer.android.com/guide/topics/ui/notifiers/notifications.html#CustomNotification –