@Sushkov
">alert("yohoho")

Как сделать оповещение с большим текстом?

использую код:
public void sendBigTextStyleNotification(View view) {
		//To set large icon in notification
		Bitmap icon1 = BitmapFactory.decodeResource(getResources(),
				R.drawable.ic_launcher);

//Assign inbox style notification
		NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle();
		bigText.bigText("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.");
		bigText.setBigContentTitle("Big Text Notification");
		bigText.setSummaryText("By: Author of Lorem ipsum");

//build notification
		NotificationCompat.Builder mBuilder =
				new NotificationCompat.Builder(this)
						.setSmallIcon(R.drawable.ic_launcher)
						.setContentTitle("Big Text notification")
						.setContentText("This is test of big text style notification.")
						.setLargeIcon(icon1)
						.setStyle(bigText);

// Gets an instance of the NotificationManager service
		NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

//to post your notification to the notification bar
		mNotificationManager.notify(0, mBuilder.build());
	}


Но большого текста нет, только строки "Big Text notification" и "This is test of big text style notification." , пробовал на 4.2 и 5.
  • Вопрос задан
  • 229 просмотров
Решения вопроса 1
@jestev
Люблю iOS
Попробуйте этот код
.setStyle(new Notification.BigTextStyle()
         .bigText(aVeryLongString))

А вот полный код для примера:
Notification notif = new Notification.Builder(mContext)
     .setContentTitle("New mail from " + sender.toString())
     .setContentText(subject)
     .setSmallIcon(R.drawable.new_mail)
     .setLargeIcon(aBitmap)
     .setStyle(new Notification.BigTextStyle()
         .bigText(aVeryLongString))
     .build();
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы