cen*_*ree 24 android google-cloud-messaging
我的Android应用程序必须能够向一大群人发送简短的警报.显而易见的地方是通知中心.完整通知显示在自动收报机中没有问题,但在通知中心,用户只能看到前几个单词,然后是省略号.通知不长,最多只有10-15个字.如何将文本换行到新行?
我在这里构建通知的代码
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.splash)
.setContentTitle("Student Engauge")
.setContentText(extras.getString("message"))
.setAutoCancel(true)
.setTicker(extras.getString("message"));
final int notificationId = 1;
NotificationManager nm = (NotificationManager) getApplicationContext()
.getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(notificationId, mBuilder.build());
Run Code Online (Sandbox Code Playgroud)
Asw*_*ran 45
要显示大块文本,请使用BigTextStyle.以下是BigTextStyle中给出的示例代码.此通知将包含一行文本,并在需要时将扩展为更多行.
Notification noti = new Notification.Builder()
.setContentTitle("New mail from " + sender.toString())
.setContentText(subject)
.setSmallIcon(R.drawable.new_mail)
.setLargeIcon(aBitmap)
.setStyle(new Notification.BigTextStyle()
.bigText(aVeryLongString))
.build();
Run Code Online (Sandbox Code Playgroud)
对于android支持库
Notification noti = new Notification.Builder()
.setContentTitle("New mail from " + sender.toString())
.setContentText(subject)
.setSmallIcon(R.drawable.new_mail)
.setLargeIcon(aBitmap)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(aVeryLongString))
.build();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20621 次 |
| 最近记录: |