Android的:无法显示在通知多行文本 [英] Android : Unable to display multiple lines of text in Notification
本文介绍了Android的:无法显示在通知多行文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想显示 BigTextStyle
多行文本的使用通知,但未能如愿。我使用下面的code。
I am trying to display multiple lines of Text using BigTextStyle
in Notification but unable to do so. I am using the code below.
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, 0, new Intent(this,
MainActivity.class), 0);
}
我甚至不能看到MSGTEXT的通知。知道为什么吗?
感谢您的帮助。
I can't even see 'msgText' in the notification. Any idea why? Thanks for helping.
推荐答案
解决了!
code是罚款,对于大的通知它只是没有足够的空间。当我断开数据线,它得到了显示所需的方式。 : - )
Code was fine, its just that there was not enough space for big notification. When I disconnected data cable, it got displayed in desired manner. :-)
感谢所有谁试图帮助。
这篇关于Android的:无法显示在通知多行文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文