Android:无法在通知中显示多行文本

前端之家收集整理的这篇文章主要介绍了Android:无法在通知中显示多行文本前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我试图在通知中使用BigTextStyle显示多行文本,但无法这样做.我正在使用下面的代码.

@H_404_5@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’.知道为什么吗?
谢谢你的帮助.

最佳答案
解决了!

代码很好,只是没有足够的空间进行大通知.当我断开数据线时,它以所需的方式显示.

猜你在找的Android相关文章