我试图在通知中使用BigTextStyle显示多行文本,但无法这样做.我正在使用下面的代码.
public void sendNotification(View view) {
String msgText = "Jeally Bean Notification example!! "
+ "where you will see three different kind of notification. "
+ "you can even put the very long string here.";
NotificationManager notificationManager = getNotificationManager();
PendingIntent pi = getPendingIntent();
android.app.Notification.Builder builder = new Notification.Builder(
this);
builder.setContentTitle("Big text Notofication")
.setContentText("Big text Notification")
.setSmallIcon(R.drawable.ic_launcher).setAutoCancel(true)
.setPriority(Notification.PRIORITY_HIGH)
.addAction(R.drawable.ic_launcher,"show activity",pi);
Notification notification = new Notification.BigTextStyle(builder)
.bigText(msgText).build();
notificationManager.notify(0,notification);
}
public NotificationManager getNotificationManager() {
return (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
}
public PendingIntent getPendingIntent() {
return PendingIntent.getActivity(this,new Intent(this,MainActivity.class),0);
}
我甚至无法在通知中看到’msgText’.知道为什么吗?
谢谢你的帮助.
最佳答案